Solve constraint problems with backtracking
8 steps · about 3 h 15 min · Intermediate
- See search as a decision tree (guide, Cornell University, 20 min)
Connects recursive choices to a tree whose branches can succeed, fail or be pruned.
- Count the unpruned search space (reference, Python Software Foundation, 15 min)
Combinations provide a baseline for understanding how much work useful constraints can avoid.
- Model constraints with n-queens (guide, Google for Developers, 20 min)
The classic problem makes row, column and diagonal conflicts concrete before implementation.
- Trace choices and undo steps (interactive, University of San Francisco, 20 min)
Shows the search advancing and retreating as placements violate constraints.
- Combine propagation with search (guide, Peter Norvig, 30 min)
A readable Sudoku solver demonstrates that strong pruning can matter more than clever recursion.
- Generate combinations without duplicates (interactive, GeeksforGeeks, 25 min)
Tests start indices, solution copying and the difference between a partial path and a finished answer.
- Backtrack on a grid (interactive, GeeksforGeeks, 30 min)
Requires marking and restoring state correctly while pruning paths that cannot match the word.
- Finish with constrained enumeration (interactive, GeeksforGeeks, 35 min)
Brings choice ordering, conflict sets, undo and all-solution enumeration into one testable program.