Tower of Hanoi: Play the Puzzle Online

Play the Tower of Hanoi puzzle free in your browser. Move the whole stack of disks from the left rod to the right rod, one disk at a time, without ever putting a bigger disk on a smaller one. Choose 3 to 8 disks, try to finish in the fewest moves, or watch the solver do it.

0Moves
15Minimum moves
0:00Time

Quick answer: Click a rod to pick up its top disk, then click another rod to drop it there (or press keys 1, 2 and 3). Only one disk moves at a time, and a disk can never sit on a smaller one. Move the full tower to the right-hand rod to win. The smallest possible number of moves is 2n − 1, where n is the number of disks.

How to solve the Tower of Hanoi

  1. To move a tower of n disks, first move the top n − 1 disks out of the way onto the spare rod.
  2. Move the biggest disk to the target rod.
  3. Move the n − 1 disks from the spare rod on top of it.
  4. Each smaller tower is solved the same way, which is why the puzzle is a classic example of recursion.

A handy pattern: move the smallest disk every other turn, always in the same direction (to the right with an odd number of disks, to the left with an even number, wrapping around), and in between make the only other legal move.

Minimum moves for each Tower of Hanoi size

DisksMinimum moves
37
415
531
663
7127
8255

The puzzle was invented by the French mathematician Édouard Lucas in 1883. A legend he told says monks are moving 64 golden disks; at one move per second, that would take about 585 billion years.

More brain games: sliding puzzle, peg solitaire and dots and boxes.

FAQ

Is the Tower of Hanoi good for kids?

Yes. Start with 3 disks, which takes just 7 moves, then add a disk once it feels easy. It builds planning and step-by-step thinking.

Why is the puzzle used in computer science?

Its solution breaks a big problem into the same problem at a smaller size, which makes it a favorite first example of recursive algorithms.

More free games and tools

See all of them on the QuickOnlineTips free online tools page and the free online games page.

Found this useful? Share it with someone who needs it.