Solving Every Sudoku Puzzle (2006) (norvig.com)

🤖 AI Summary
This essay demonstrates a compact, practical Sudoku solver that reliably solves every puzzle by combining constraint propagation with targeted search. The board is modeled symbolically: 81 named squares (A1–I9), 27 units (rows, columns, 3x3 blocks) and a peers set for each square. The internal state is a dict mapping each square to a string of possible digits (a single digit if decided). Two cheap, powerful propagation rules are implemented: (1) if a square is reduced to one value, eliminate that value from all peers; (2) if a unit has only one place for a digit, assign it there. The core functions are eliminate (which enforces propagation and detects contradictions) and assign (which eliminates all other digits from a square). Parsing, unit/peer construction, and display are a few lines each. When propagation alone stalls on hard puzzles, a short recursive search/backtracking layer tries assignments, guided by propagation to prune inconsistent branches. Simple heuristics (choose the square with fewest possibilities) dramatically reduce the branching factor; optional small tactics like “naked twins” can be added easily. Significance: the essay is an elegant, instructive example of constraint satisfaction in practice—showing how careful representation, local propagation, contradiction detection, and minimal search combine into a small, readable solver that illustrates core AI techniques applicable beyond Sudoku.
Loading comments...
loading comments...