Sudoku Solver — Backtracking with MRV and Candidate Sets
Watch depth-first backtracking fill cells. The MRV heuristic picks the empty cell with the fewest candidates; a dead-end cell (0 candidates) triggers a backtrack.
step 0
Grid
given placed MRV cell dead end
Search state
placements
0
backtracks
0
empty cells left
0
recursion depth
0
solve():
cell = findMRV() // fewest candidates
if none: return true // solved
if 0 candidates: return false
for d in candidates:
place d; if solve(): return true
undo d // backtrack
return false
Press Step to begin. The solver finds the most-constrained empty cell, tries each legal digit, and backtracks on a dead end.
Self-contained visualization. Small digits in an empty cell are its current candidate set (digits not used by its row, column, or 3×3 box).
The cell outlined in amber is the MRV choice (fewest candidates). See junior.md and middle.md for the bitmask + MRV solver this animates.