Sudoku
Sudoku from a software developer's point of view: how hard is a puzzle really, and how does a program solve one that is not meant to be easy?
How the solver works
Elimination first: every empty cell that has exactly one possible digit left is filled, again and again, until nothing changes. A puzzle that falls to this step alone is an easy one.
Backtracking for the rest: the solver picks the cell with the fewest candidates, tries one, and continues. A dead end undoes the guess. The number of guesses it needed is a fair measure of the puzzle's difficulty.
The generator builds a random complete grid and removes cells one by one, keeping only removals that leave exactly one solution. So every generated puzzle has exactly one solution.
Loading…