Tower of Hanoi

Move the whole stack, one disk at a time. Free · no download · works on phone & desktop

Moves0
Best0
Time0:00

Move all 4 disks to peg C · fewest moves 15

Tap a peg to lift its top disk, then tap another peg · Never put a bigger disk on a smaller one

About Tower of Hanoi

Tower of Hanoi is the classic disk-stacking puzzle invented by the French mathematician Édouard Lucas in 1883. A stack of disks sits on the left peg, largest at the bottom. Move the whole stack to the right peg, one disk at a time, and never place a bigger disk on top of a smaller one. With n disks the fewest moves possible is 2ⁿ − 1: 7 moves for 3 disks, 15 for 4, and 1,023 for 10. Pick 3 to 10 disks, ask for a hint from any position, or watch the computer solve the rest.

How to play

  1. Tap a peg to lift its top disk, then tap the peg you want to move it to. You can also drag from one peg to another, or use the keys 1, 2 and 3.
  2. Only the top disk of a peg can move, and it can only land on an empty peg or on a bigger disk.
  3. Move every disk to peg C, in order, to solve the puzzle.
  4. Solve it in the fewest possible moves (2ⁿ − 1) for three stars.
  5. Change the number of disks (3–10) in the settings.

Tips & strategy

  • The smallest disk moves on every other turn. Always move it in the same direction around the pegs: with an even number of disks go A → B → C → A, with an odd number go A → C → B → A.
  • On the turns between, there is exactly one legal move that does not touch the smallest disk.
  • Think recursively: to move 5 disks to C, first move the top 4 to B, move the big disk to C, then move the 4 back on top of it.

Frequently asked questions

What are the rules of Tower of Hanoi?

Move the whole stack from the first peg to the last peg. Move one disk at a time, only the top disk of a peg, and never put a larger disk on a smaller one.

What is the minimum number of moves?

For n disks it is 2ⁿ − 1: 7 moves for 3 disks, 15 for 4, 31 for 5, 63 for 6, and 1,023 for 10. Matching it earns three stars.

How do you solve Tower of Hanoi?

To move n disks, move the top n − 1 disks out of the way to the spare peg, move the largest disk to the target, then move the n − 1 disks on top of it. The same idea repeats for each smaller stack. The Hint button shows the best next move from any position.

How long would 64 disks take?

The legend tells of priests moving 64 golden disks. That needs 2⁶⁴ − 1 moves, about 18.4 quintillion; at one move per second it would take roughly 585 billion years.

Who invented Tower of Hanoi?

The French mathematician Édouard Lucas published it in 1883, under the pen name “N. Claus de Siam”, together with the legend of the temple tower.

Languages

EN

← Browse all games