Three pegs. A stack of disks on the first peg, largest at the bottom. Move the entire stack to the third peg, one disk at a time, never placing a larger disk on a smaller one. That's the whole puzzle. What makes it worth studying is that the only sane way to solve it is to trust recursion completely, even when it feels like cheating.
Click a peg to pick up its top disk, click another peg to drop it there. Illegal moves are simply refused. Get all disks onto peg C to win.
Moves: 0
Trying to plan every single move in advance is exactly why this puzzle feels impossible. The recursive solution refuses to do that. It only ever thinks about the biggest disk.
To move n disks from a source peg to a destination peg, using a spare peg to help:
Steps 1 and 3 are exactly the same kind of problem as the original, just with one fewer disk. That's the whole trick: you never need to know how to move n-1 disks, you just trust that the same three-step recipe handles it, all the way down to a single disk, which is trivial to move directly.
Every move below comes from the exact recursive recipe above, nothing hardcoded. Step through and watch the pattern: it obsessively clears disks out of the way, moves one big disk, then puts them back.
Move 0 of 0
Each box is one call to the recursive procedure. Notice it branches, just like Fibonacci, but here there's no repeated work, every branch handles a genuinely different sub-problem, which is exactly why memoisation has nothing to offer this algorithm.
Each call to move n disks makes exactly two recursive calls to move n-1 disks, plus one move of its own. That single sentence is enough to derive the whole formula.
Let T(n) = number of moves needed for n disks.
T(n) = T(n-1) + 1 + T(n-1) = 2×T(n-1) + 1
T(1) = 1 (just move the one disk)
T(2) = 2×1 + 1 = 3
T(3) = 2×3 + 1 = 7
T(4) = 2×7 + 1 = 15
T(n) = 2n - 1