Generate a puzzle and its solution.
[puzzle,solution] = sudoku_generate3 ( difficulty )
the level of the puzzle, difficulty=1 is easy, difficulty=2 is medium, difficulty=3 is more difficult
the 9x9 puzzle matrix, with zeros for unknown entries
the 9x9 solution matrix without any zero
Generates a random sudoku with sudoku_fillrandom. Then delete some entries according to the difficulty. Solves the puzzle and the transposed puzzle. If the two solutions are equal, the solution is probably unique: returns it. If not, continue to generate puzzles until unicity is achieved. This algorithm is less slow (typically less than 30 seconds).
"Enumerating possible Sudoku grids", Bertram Felgenhauer, Frazer Jarvis, June 2005