Brain Games

Tower of Hanoi

Move the whole stack to the right peg. Only one disc at a time, and never a bigger disc on top of a smaller one.

Moves 0Best possible 150.0 s

Tap a peg to lift its top disc. Move the whole tower to the right peg.

This game runs in your browser. Nothing you do here is sent to a server.

How to play

  1. Pick how many discs you want. 3 is quick, 7 takes real planning.
  2. Tap a peg to lift its top disc. It rises a little so you can see it's picked up.
  3. Tap another peg to drop it there. Tap the same peg again to put it back.
  4. On a keyboard, keys 1, 2 and 3 pick the left, middle and right peg.
  5. Get all the discs onto the right peg. Try to match the best possible number of moves shown at the top.

The rules

There are three pegs and a stack of discs, biggest at the bottom. You move one disc at a time, and you can only take the top disc from a peg.

A disc can go on an empty peg or on a bigger disc. It can never go on a smaller one.

The fewest moves

With n discs the shortest solution takes 2ⁿ − 1 moves: 7 for 3 discs, 15 for 4, 31 for 5, 63 for 6 and 127 for 7.

Each extra disc doubles the work plus one. To move 5 discs you move the top 4 out of the way, move the biggest disc, then move the 4 back on top of it.

A simple way to solve it

Move the smallest disc on every other turn, always in the same direction around the three pegs. In between, make the only legal move that doesn't touch the smallest disc.

Which way should the smallest disc go? With an odd number of discs, its first move is straight to the right peg. With an even number, its first move is to the middle peg. Follow that and you'll finish in the fewest moves.

Where the puzzle comes from

The French mathematician Édouard Lucas published the puzzle in 1883. It came with a story about monks moving 64 golden discs, and the world ending when they finish.

At one move per second, 64 discs would take 2⁶⁴ − 1 seconds, which is about 585 billion years. So no need to worry.

Psychologists use towers like this to look at planning. A close cousin, the Tower of London test, was designed by Tim Shallice in 1982.

FAQ

What is the minimum number of moves for the Tower of Hanoi?
2ⁿ − 1, where n is the number of discs. That's 7 moves for 3 discs, 15 for 4, 31 for 5, 63 for 6 and 127 for 7.
Is there a trick to solving it?
Yes. Move the smallest disc every other turn, always the same way around the pegs. Between those moves, make the one legal move that doesn't use the smallest disc.
Can I finish on the middle peg?
In this game the goal is the right peg. The puzzle works the same either way, only the direction of the smallest disc changes.
Is the Tower of Hanoi good for kids?
With 3 or 4 discs it's a nice first logic puzzle. Kids learn to think a few moves ahead. Save 6 and 7 discs for when they want a real challenge.

More brain games

Last updated 2026-11-06