Skip to content
One Quick Try

Tower of Hanoi

Move the whole stack to the last peg, one disk at a time, never a big disk on a small one.

Type
Logic
Takes
about 1-5 min
Result in
moves

Tower of Hanoi

~1-5 min

  1. Move the whole stack from the left peg to the right peg.
  2. Move one disk at a time: tap a peg to lift its top disk, then tap where it goes.
  3. A disk can never sit on a smaller one.
Disks

1 2 3 work too. The clock starts on your first move.

Your result: — moves

How it's measured
  • River Crossing

    Get everyone across the river safely.~2-5 min
  • Lights Out

    Turn off every light. Each press flips its neighbors.~1-3 min
  • Water Jug

    Measure an exact amount with unmarked jugs.~1-4 min
  • Make 24

    Use all four numbers to make 24.~2-4 min
  • Peg Solitaire

    Jump pegs until only one is left.~3-6 min
  • Chinese Rings

    Take every ring off the bar.~2-5 min

The rules

  • All the disks start on the left peg, largest at the bottom.
  • Move them all to the right peg.
  • Move one disk at a time, and only the top disk of a peg.
  • Never put a disk on top of a smaller one.

How to play it here

Pick 3 to 7 disks (4 is a good start). Tap a peg to lift its top disk, then tap the peg where it should go. Tap the same peg again to put the disk back down. On a keyboard, 1, 2 and 3 tap the three pegs and Escape puts a lifted disk back. An illegal move doesn't count: the disk stays where it was and you see why.

How we calculate your result

The clock starts on your first move, not when you press Start, so you can look at the puzzle and plan first. It stops on the move that completes the stack. You see your time, your number of moves, and the fewest moves possible for that many disks. Matching the minimum means you found the perfect solution.

What does my rating mean?

The rating compares your moves with the fewest possible, so it needs no averages: exactly the fewest is Perfect, and the more moves you add, the lower the rating. The moves that earn each rating:

Rating (moves)3 disks4 disks5 disks6 disks7 disks
Perfect7153163127
Excellent816–1732–3564–72128–146
Good918–2036–4173–85147–171
Fair10–1221–2742–5586–113172–228
Keep trying13+28+56+114+229+

The fewest moves

The minimum for n disks is 2n − 1. The reason is neat: to move the bottom disk, every other disk must first be moved out of the way onto the middle peg, which is the same puzzle with one disk fewer. Then the bottom disk moves once, and the smaller stack moves again on top of it. So each extra disk doubles the work and adds one move.

DisksFewest moves
37
415
531
663
7127

A strategy that always works

Move the smallest disk on every other move, always in the same direction around the pegs. With an odd number of disks it goes left peg, right peg, middle peg, left peg and so on. With an even number it goes left, middle, right. On the moves in between, make the only legal move that doesn't involve the smallest disk. Follow that and you solve it in the minimum number of moves.

The legend

The puzzle was invented by the French mathematician Édouard Lucas in 1883, and sold with a story about priests moving a tower of 64 golden disks, with the world ending when they finished. At one move per second, 264 − 1 moves would take about 585 billion years.

Want another puzzle that rewards planning ahead? Try the River Crossing Puzzle or Make 24.

Questions

How many disks should I start with?
4 disks takes 15 moves at best and is a good first try. Each extra disk roughly doubles the length, so 7 disks needs at least 127 moves.
Does the clock start when I press Start?
No, on your first move. Time spent looking at the puzzle before you begin is free.
Do illegal moves count?
No. A disk can't be put on a smaller one, so the move doesn't happen and your move count stays the same.
Can I move the stack to the middle peg instead?
Not here. The puzzle is solved only when every disk is on the right-hand peg.
How do you solve the Tower of Hanoi with 5, 6 or 7 disks?
The same way as with any number: move the smallest disk on every other move, always the same way round, and make the only other legal move in between. It takes 31, 63 and 127 moves at best for 5, 6 and 7 disks.
What is the difference between the Tower of Hanoi and the Tower of London?
The Tower of London is a planning test based on the Tower of Hanoi, devised by the neuropsychologist Tim Shallice in 1982. It uses balls of the same size on pegs of different heights, and asks you to reach a goal arrangement in a set number of moves. It is used in clinical neuropsychology; the Tower of Hanoi here is a puzzle.