The Tower of Hanoi has a reputation as a brain-melter, and a secret: there is a mechanical method that solves any stack in the provably minimal number of moves, without ever thinking ahead. This guide teaches the method, the recursion it secretly implements, and the first-move rule that trips everyone. Practice on our free Tower of Hanoi.
The two-step loop that never fails
Alternate exactly two actions. Move one: move the SMALLEST disk one peg along a fixed direction (say, always to the right, wrapping from the last peg back to the first). Move two: make the only legal move that does NOT involve the smallest disk, there is always exactly one. Repeat. That is the entire method; it produces the optimal solution every time, and executing it feels faintly like being possessed by a mathematician.
The first-move rule
Where should the first disk go? It depends on the stack's parity. With an ODD number of disks, move the smallest disk directly toward the target peg; with an EVEN number, move it to the spare peg. Get this one choice wrong and the method still 'works', but delivers the tower to the wrong peg, the most common way people convince themselves the puzzle is unfair.
Why it works: the recursion underneath
The puzzle's true structure: to move n disks, you must move the top n-1 aside, carry the biggest disk across, then bring the n-1 back on top. Each of those n-1 moves contains the same idea one size smaller, recursion made physical, which is why every computer science course uses it. The smallest-disk cycle is just this recursion flattened into a rhythm your hands can follow.
The numbers to know
Minimum moves are 2^n minus 1: three disks take 7, four take 15, five take 31, each added disk doubles the work plus one. (The legend's 64-disk temple stack would take 585 billion years at a move per second, the world is safe.) If your solve beats none of these numbers, the smallest-disk cycle broke somewhere, usually right after a distraction.
From method to mastery
Once the loop is automatic, graduate to seeing the sub-towers: notice how the top three disks travel as a unit while disk four waits, and you are reading the recursion directly. That is the difference between executing the solution and understanding it, and it is weirdly satisfying to feel the switch happen mid-solve.
FAQ
What is the minimum number of moves for the Tower of Hanoi?
2^n minus 1 for n disks: 7 moves for three, 15 for four, 31 for five. Each extra disk doubles the total plus one, because you must solve the whole smaller puzzle twice around the big disk's single move.
Where should the first move go?
Odd disk count: move the smallest disk straight to the target peg. Even count: to the spare peg. This parity rule is what makes the mechanical method land the tower on the correct peg.
Is there a way to solve it without planning ahead?
Yes, the two-step cycle: move the smallest disk one peg in a fixed rotating direction, then make the only other legal move, and repeat. It provably produces the optimal solution for any stack size.