The Tower of Hanoi

Move the tower one disk at a time, never placing larger on smaller. The optimal solution is the poster child of recursion — solve the smaller tower, twice — but the deeper picture is the map of every position the puzzle can reach: it's a Sierpiński triangle, and solving the puzzle is walking one straight edge of it.

view
Tower of Hanoi boardABC4321
Three pegs, one rule: a disk may never rest on a smaller disk. Click a peg to lift its top disk, click another peg to drop it. Move the whole tower onto C.
disksrecord: 15 moves
Step 1 of 5 — One rule

To move a mountain: move everything above it out of the way, move the base, then put everything back. Read that again — the phrase "move everything above it" is the same instruction, one disk smaller. The sentence calls itself, and the entire solution is that one sentence dropped into a mirror.

You never have to plan a whole solution. You only have to trust that the smaller version already works — which is exactly what you do when you climb a staircase without thinking about the staircase. The cost of that trust is the doubling: each extra disk means doing the old job twice, plus one.

The surprise is what the puzzle looks like from above. Draw a dot for every position and a line for every legal move, and the picture is not a tangle: it is a perfect Sierpiński triangle, with the three finished towers at its three corners. Solving the puzzle is walking one straight side. Fumbling it is wandering into the middle.