Tower of Hanoi

Tower of Hanoi

Sudoku & logic
Free · no download
Tower of Hanoi
Sudoku & logic · Free · no download

Tower of Hanoi

The Tower of Hanoi is a puzzle of three pegs and a stack of disks, largest at the bottom. Your job is to move the whole tower from the left peg to the crowned peg on the right, one disk at a time, without ever placing a disk on a smaller one. The tower is set up and waiting on this page: tap the left peg to lift its top disk and begin.

It looks simple with three disks and becomes a real test of patience with eight, which is why the Tower of Hanoi game has long been a favourite of puzzle lovers and maths teachers alike.

How it works

Tap a peg to pick up its top disk, then tap another peg to drop it there. You can also drag a disk from peg to peg, or press 1, 2 and 3 on a keyboard to choose pegs, with Esc to cancel a lift.

If you try to put a disk on a smaller one, the disk shakes and nothing happens. The bar shows Time, Moves and the Minimum: the fewest moves the tower can be moved in. Match that number and you have played perfectly.

Disks and levels

Each extra disk roughly doubles the work: the minimum is always two to the power of the number of disks, minus one. The tower always starts on the left peg, so you can practise the same pattern until it feels natural.

  • Easy: 4 disks, minimum 15 moves.
  • Medium: 6 disks, minimum 63 moves.
  • Hard: 8 disks, minimum 255 moves.

Tips

  • Watch the smallest disk. In a perfect solution it moves on every other turn, always travelling round the pegs in the same direction.
  • With an even number of disks, the smallest disk's first move goes to the middle peg; with an odd number, straight to the target.
  • Between moves of the smallest disk there is only ever one legal move that does not touch it. Make that move and continue.
  • Think in sub-towers: to move six disks, first move the top five out of the way, then the biggest disk, then the five back on top.
  • The score rewards being close to the minimum and also counts time, so a smooth rhythm matters more than speed.

Help when you need it

The Hint button, unlocked with a short video, highlights the disk to move and the peg to move it to. It works from any legal position, even after a few detours, and always follows the shortest way from where you are. Undo takes back your last move but adds to the move counter. The full rules and the recursive idea behind them are explained in how to play Tower of Hanoi.

FAQ

What is the minimum number of moves?
Two to the power of the number of disks, minus one: 15 for four disks, 63 for six, 255 for eight. The game shows it in the bar as Minimum.
Is there an algorithm for the Tower of Hanoi?
Yes, a famous recursive one: move all but the bottom disk aside, move the bottom disk, then move the rest on top. The rules page walks through it.
Can I start with a different number of disks?
There are three levels: 4, 6 or 8 disks. Pick one in the New game dialog.
Does the hint still work after I make a mistake?
Yes. It always shows the best next move from your current position.
What should I play next?
The Sliding Puzzle and Box Pusher are fellow classics that reward thinking a few steps ahead.

More games

View all

Privacy settings

Choose which optional cookies and similar technologies we may use. You can change this at any time with the “Privacy settings” link at the bottom of every page.

Strictly necessaryAlways on

Keep your saved games, sound and language settings and this choice on your device. Always on, because the site cannot work properly without them.

Anonymous statistics that show us which games and pages are used, so we can improve them.

Lets Google and its partners use cookies to personalise ads and measure them. If this is off, you may still see ads, but they won't be based on your interests. Turning it off also opts you out of the “sale” or “sharing” of your personal information.