Chaoschemy

Puzzle · Logic

Tower of Hanoi game: rules, stars and the trick

Move a stack of alchemy potion disks from the first glass peg to the last, one disk at a time. Six levels from 3 to 8 disks, and the method below solves every one in the fewest moves.

6 levels · 3 to 8 disks · 7 to 255 moves at bestFree · No account needed

Start a game

Play Tower of Hanoi

Start with 3 disks: 7 moves earns 3 stars. Each new level adds one disk and roughly doubles the moves, up to 255 for 8 disks.

Tower of Hanoi cover art

A free Tower of Hanoi game with alchemy potion disks. Move the stack to the last peg in 6 levels from 3 to 8 disks, with stars for the fewest moves, a timer, hints and best scores.

How to play

  1. Every disk starts on peg A, biggest at the bottom. The goal is the same stack on peg C on the right.
  2. Move one disk at a time, and only the top disk of a peg. A disk may go on an empty peg or on a bigger disk, never on a smaller one; the game tells you when a move is not allowed.
  3. Tap a peg to lift its top disk, then tap the peg where it should go, or drag the disk across. Tap the same peg again to put it back.
  4. The fewest possible moves for n disks is 2 to the power n, minus 1. Finish in exactly that many for 3 stars, within half as many again for 2 stars, or any finish for 1.
  5. Undo takes a disk back, but the move still counts. Hint shows the best next move from wherever you are, even after mistakes, and caps the round at 2 stars.
  6. The timer starts with your first move and pauses when you choose Pause or leave the tab. Every level is open from the start, so pick any one and chase 3 stars.

Controls

Mouse
Click a peg to lift its top disk, then click the peg to drop it on, or drag the disk to another peg.
Touch
Tap a peg, then tap where the disk goes, or drag it across with your finger.
Keyboard
Keys 1, 2 and 3 pick pegs A, B and C; Escape puts a lifted disk back. Tab reaches each peg; Enter or Space picks it.

Score and progress

The move counter adds one for every disk you move, and undone moves still count. The best possible count for the level is shown beside it. The timer has no limit and stops when the stack is complete. Best stars, fewest moves and fastest time are saved separately for each level in this browser when local storage is available.

Tips

Want to watch the shortest solution? The game opens your current position in the Tower of Hanoi solver, which plays and lists the fewest moves from there.

How to solve the Tower of Hanoi

The puzzle looks long, but every level is the smaller one with a single extra step. That is the recursive idea, and it gives both the fewest moves and a routine you can follow by hand.

  1. To move a stack of n disks from A to C, first move the top n − 1 disks from A to B, using C as the spare.
  2. Move the biggest disk from A to C. It is now home and never moves again.
  3. Move the n − 1 disks from B onto it on C, using A as the spare. Each of those smaller moves is solved by the same three steps.
  4. Count the moves: moving n disks takes twice the moves for n − 1 disks, plus one. Starting from 1 move for one disk, that gives 3, 7, 15, 31, 63, 127 and 255, which is 2 to the power n, minus 1.
  5. By hand, use the smallest-disk routine: on every odd move, move the smallest disk one peg along, always the same way round (A to C to B to A with an odd number of disks, A to B to C to A with an even number). On every even move, make the only legal move that does not touch the smallest disk.

Recovering after a wrong move

You do not need to restart after a mistake. Look at the biggest disk that is not yet on peg C. Every smaller disk has to be gathered on the one peg that is neither its peg nor C; then that big disk moves across, and the smaller ones follow it. Repeat with the next biggest disk that is out of place. That is exactly how Hint picks its move, and it is always the shortest way to finish from where you are.

Questions before you play

What is the fewest number of moves in the Tower of Hanoi?

2 to the power of the number of disks, minus 1: 7 moves for 3 disks, 15 for 4, 31 for 5, 63 for 6, 127 for 7 and 255 for 8. Finishing in exactly that many moves earns 3 stars.

How do you solve the Tower of Hanoi?

Think in stacks. To move n disks, move the top n − 1 disks to the spare peg, move the biggest disk to the goal peg, then move the n − 1 disks back on top of it. Each smaller stack is solved the same way.

Is there an easy trick to remember?

Yes. Move the smallest disk every other turn, always in the same direction round the pegs: A to C to B for an odd number of disks, A to B to C for an even number. In between, make the only legal move that does not touch the smallest disk.

How are stars earned?

3 stars for the fewest possible moves, 2 stars within half as many moves again, and 1 star for any finish. Using Hint caps the round at 2 stars, and a move you undo still counts.

What is the difference between this game and the Tower of Hanoi solver?

The game is a level-by-level challenge with stars, a timer and saved best scores. The free Tower of Hanoi solver shows and plays the shortest solution from any position, and the game links your current position to it.