How the generator guarantees one solution
A finished Sudoku worksheet should have one answer, not merely an answer. That difference matters in a classroom: if two completions are possible, a careful student can disagree with the answer key and still be correct.
This generator protects against that problem in three steps. First it makes a complete grid in which every row, column, and box follows the rules. Second it shuffles the order of the squares using the worksheet code. Third it removes one clue and asks a solver how many completions are still possible. The solver stops after finding two because two is already enough to prove that the puzzle is ambiguous.
- If the solver finds exactly one completion, the clue stays removed.
- If it finds two, the clue goes back before the generator tries another square.
- The process repeats until the selected clue count is reached.
The worksheet code controls every shuffle, so the same code and settings repeat the same choices in the same order. Reproducibility and uniqueness are both part of the puzzle, rather than checks added after printing.