← All animations

✏️ Sudoku Solver

A Sudoku puzzle is a logic grid with three iron rules: every row, every column, and every 3×3 box must contain the digits 1–9 exactly once. A computer doesn't "see" the pattern — it searches. Below you can watch a solver try digits, hit dead ends, back up, and eventually fill in the answer — then switch on smarter reasoning and see the search collapse.

1. Backtracking — guess, check, recurse, back up

The solver walks to the first empty cell and tries 1, 2, 3… For each candidate it checks the row, column, and box. A digit that fits is placed (it might still be wrong) and the solver moves on; when a cell runs out of legal digits, it backs up — erasing its last guess and trying the next number there. This depth-first trial and error is guaranteed to find the solution if one exists. Type your own puzzle by clicking a cell and pressing 1–9 (or 0 / Backspace to clear).

solved / placed active cell tried & rejected given clue
Ready · 0 steps

2. Constraint propagation — think before you guess

Pure backtracking is dumb: it will happily try a digit a human can see is impossible. Constraint propagation reasons first. Each empty cell carries pencil marks — the digits still possible there. Place any clue and you erase that digit from its row, column, and box, shrinking neighbours' marks. When a cell's marks shrink to one digit (a "naked single"), it's forced — fill it in, which shrinks its neighbours, and the deductions cascade. Watch the candidate counts fall, then compare how many backtracking steps each strategy needs.

Pencil marks shown · click a clue to watch it propagate
—
brute backtracking steps
—
with constraint propagation
0
singles filled by logic alone

3. Why it works — and why it's hard