Visualize how a Sudoku solver uses backtracking to find the correct numbers. Step-by-step animation of trial and error logic.
A constraint satisfaction problem solved using a depth-first search through the space of possible digit placements.
A number (1-9) can only be placed if it is not already present in: 1) The current row, 2) The current column, 3) The 3×3 subgrid (box).
The algorithm finds an unassigned cell (row, col) and tries assigning digits from 1 to 9. If a digit works, it marks the cell and recursively tries to solve the rest of the board.
When a placement is invalid, we visualize the conflict by highlighting the offending row, column, or box in red. This shows exactly why the algorithm must try a different number.
Backtracking is effective here because it abandons a "branch" of the search as soon as a single cell cannot be filled with any of the 9 digits, saving billions of unnecessary checks.
The Sudoku solver is a perfect example of a Depth First Search (DFS) on a state-space tree where the depth is the number of empty cells.