Mental Royale
All techniques

How Computers Solve Sudoku

Guide3 / 4

Backtracking brute force vs. the technique catalog — and why we use both.

A computer can solve any sudoku in a millisecond without knowing a single technique. So why does this site carry a solver that thinks in X-Wings and chains? Because the two kinds of solver answer different questions.

Backtracking: the sledgehammer

The classic algorithm fills the first empty cell with the lowest legal digit, moves on, and whenever it hits a dead end, backs up and tries the next digit. Add the obvious bookkeeping — always work on the most constrained cell first — and any 9×9 sudoku collapses in milliseconds.

Backtracking answers 'what is the solution?' and, just as importantly, 'how many solutions are there?': run the search past the first hit and see whether a second one exists. That uniqueness check is the backbone of puzzle generation — and the reason techniques like the Unique Rectangle are safe to use at all.

The technique solver: the teacher

Our second solver knows the same catalog of techniques you can learn here, ordered from trivial to fierce. At every position it asks: what is the simplest technique that makes progress? The result is not just a solution but a solve path — a human-shaped explanation of the puzzle.

That path powers almost everything on this site: the hint system shows you its next step instead of a bare digit, the grader reads the path's hardest technique to assign a tier, and the drill generator harvests its positions for practice.

How our generator uses both

New puzzles start as a full solved grid built by randomized backtracking. The generator then digs out cells one by one, and after every removal the backtracking solver verifies the puzzle still has exactly one solution — if not, the cell goes back in.

The dug puzzle then meets the technique solver, which decides its fate: grade it, place it into a campaign tier, or discard it as beyond the catalog. Sledgehammer for construction and certainty, teacher for judgment — that division of labor is how essentially every serious sudoku app works.