Games

Tower of Hanoi

How to play Tower of Hanoi

Game input is disabled while help is open.

Controls

Move
Click a peg to lift its top disc, then a peg to drop it · keys 1, 2, 3

How to play

Move the whole stack to the right-hand peg. Only the top disc moves, and a disc may never sit on a smaller one. The fewest moves possible is 2ⁿ − 1.

RulesMove one disc at a time, always the top disc of a peg, and never put a disc on a smaller one. The goal is the right-hand peg.
Why 2ⁿ − 1To move n discs you must first move the n − 1 above the largest out of the way, move the largest, then move the n − 1 back on top: twice the work plus one. That doubling gives 7 moves for 3 discs and 255 for 8.
A patternMove the smallest disc every other turn, always cycling in the same direction (right for an even number of discs, left for odd); the move in between is the only legal one not using it.

1 player · Mouse · Touch · Keyboard

Next game: Mental Math Sprint →
moves0fewest possible15best 4—

 

Planning

Tower of Hanoi

Move the tower to the right-hand peg, one disc at a time, never a larger disc on a smaller one.

Discs