java - Counting the number of solutions for a given sudoku puzzle? -


i'm developing web based sudoku game allows user custom made own sudoku board. need way of telling user number of possible solutions board assembled has. minimum number of entries sudoku have unique solution 17. need find number of solutions number of entries less 17.

here's method:

public long numberofsolutions (board myboard) {     this.board = myboard;     this.tempboard = new board();     long num = 0;      tempboard.copy(board);     (int = 0; < 9; i++) {         (int j = 0; j < 9; j++) {             if (board.getcell(i,j).equals(0)) {                 for(int k=1;k<10;k++){                     board.setcell(i, j, k, true);                     if(iscorrect() && solvable()){                         num++;                     }                     board.copy(tempboard);                 }             }         }     }     return num; } 

so each empty cell insert numbers 1-9 , try solve game each number. if successful increment number of solutions. doesn't me number of possible combinations, rather sum of number of numbers each cell can plugged in.

is there way can calculate ?

the answer (probably): don't that.

sudoku solving np-complete, might take while solve one, let alone counting number of solutions.

even if try compute count, might extremely large. sudoku board nothing on has 6,670,903,752,021,072,936,960 answers.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -