Move all discs to peg C โ one at a time, never larger on smaller
0
Moves
7
Optimal
โ
Best
Click a peg (or press 1, 2, 3) to pick up its top disc
๐
Solved!
The Puzzle
Three pegs โ A, B, C โ and a stack of discs on peg A, largest at the bottom. Move every disc to peg C.
The Rules
1
Only one disc can be moved at a time.
2
Only the top disc of a peg can be picked up.
3
A disc may only land on an empty peg or on a larger disc.
Minimum Moves
With n discs the minimum number of moves is always:
2n โ 1
Discs (n)
Minimum moves
3
7
4
15
5
31
6
63
The Strategy (Recursion)
To move n discs from A to C using B as a spare:
1
Move the top nโ1 discs from A โ B (using C as spare).
2
Move the largest disc from A โ C.
3
Move the nโ1 discs from B โ C (using A as spare).
Each step is the same puzzle with one fewer disc โ a classic example of recursion. The move count satisfies T(n) = 2ยทT(nโ1) + 1, giving T(n) = 2โฟ โ 1.
Example: 3 Discs (7 moves)
#
From โ To
Disc
1
A โ C
Small
2
A โ B
Medium
3
C โ B
Small
4
A โ C
Large
5
B โ A
Small
6
B โ C
Medium
7
A โ C
Small
Keyboard Shortcuts
Press a key to select/move the top disc of that peg: