Solve constraint problems with backtracking

8 steps · about 3 h 15 min · Intermediate

  1. 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.

  2. Count the unpruned search space (reference, Python Software Foundation, 15 min)

    Combinations provide a baseline for understanding how much work useful constraints can avoid.

  3. Model constraints with n-queens (guide, Google for Developers, 20 min)

    The classic problem makes row, column and diagonal conflicts concrete before implementation.

  4. Trace choices and undo steps (interactive, University of San Francisco, 20 min)

    Shows the search advancing and retreating as placements violate constraints.

  5. Combine propagation with search (guide, Peter Norvig, 30 min)

    A readable Sudoku solver demonstrates that strong pruning can matter more than clever recursion.

  6. Generate combinations without duplicates (interactive, GeeksforGeeks, 25 min)

    Tests start indices, solution copying and the difference between a partial path and a finished answer.

  7. Backtrack on a grid (interactive, GeeksforGeeks, 30 min)

    Requires marking and restoring state correctly while pruning paths that cannot match the word.

  8. Finish with constrained enumeration (interactive, GeeksforGeeks, 35 min)

    Brings choice ordering, conflict sets, undo and all-solution enumeration into one testable program.