Post by abhiI really have no idea how to write it in prolog , i did it like this
in java .. can you please give sample code for generate and test
pattern in prolog :)
int[][] best = new int[N][N];
int bestDifficulty = 0;
int bestGiven = N*N+1;
int bestTry = 0;
int tries = 0;
// Generate 100 puzzles and pick the most difficult one
while(tries < 100) {
countGiven = 0;
difficulty = 0;
// Clean the given numbers, but keep the grid intact
for(int i=0; i<N; i++) {
for(int j=0; j<N; j++) {
this.given[i][j] = 0;
}
}
// Select 17 random numbers to show
// 17 is an absolute minimum. Any less and the puzzle is
garanteed to be unsolvable.
[snip]
Hi, abhi:
Since you say you wrote this Java program, let me
ask about the comment that 17 is "an absolute
minimum." Do you have a reference for this?
I'm aware that 17-cell Sudoku exist in some
profusion, and that catalogs of the known
examples have been systematically tested to
see if any of them could be reduced to 16
cells having yet a unique solution, without
success. But I'm not aware of any proof
(by exhaustive search or otherwise) that no
16-cell Sudoku exists.
Also, it might be helpful if you explained
in more detail what the Prolog Sudoko solver
available to you does. I'd be a bit leary
of wrapping a "Sudoku generator" around such
a solver if possibly the solver code does
not terminate when presented with a puzzle
for which no solution or multiple solutions
exist. It would be interesting as well to
know what representation is used for the
solver, so that suggestions about generating
inputs could be more relevant.
regards, chip