Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void gameMake(int n){
- int wrong = 0;
- int right = 0;
- int unsolvable = 0;
- int[][] newBoard;
- System.out.println("How many empty cells per board?");
- Scanner in = new Scanner(System.in);
- int x = in.nextInt();
- long start = System.currentTimeMillis();
- int i =1;
- while(n >= i){
- newBoard = makeBoard(x);
- int[][] newBoard2 = new int[9][9];
- for(int k =0; k < newBoard.length; k++){
- for(int m = 0; m < newBoard.length; m++){
- newBoard2[k][m] = newBoard[k][m];
- }
- }
- if (!isValidBoard(newBoard)) {
- wrong++;
- } else if (isSolvableBoard(newBoard)) {
- System.out.println("Board #" + i);
- for (int k = 0; k < newBoard2.length; k++) {
- for (int m = 0; m < newBoard2.length; m++) {
- System.out.print(newBoard2[k][m] + " ");
- }
- System.out.println();
- }
- System.out.println("The solution of Board #" + i);
- for (int k = 0; k < newBoard.length; k++) {
- for (int m = 0; m < newBoard.length; m++) {
- System.out.print(newBoard[k][m] + " ");
- }
- System.out.println();
- }
- System.out.println();
- right++;
- i++;
- } else if(!isSolvableBoard(newBoard2)){
- unsolvable++;
- }
- }
- long end = System.currentTimeMillis();
- float sec = (end - start) / 1000F;
- System.out.println("Empty cells per board : "+ x);
- System.out.println("Valid boards created : "+ right);
- System.out.println("Invalid boards created : "+ wrong);
- System.out.println("Unsolvable boards created : "+ unsolvable);
- System.out.println("Elapsed time in seconds : "+ sec);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement