How to play Tower of Hanoi
You start with a stack of discs on the left peg, biggest at the bottom. Your goal is to move the whole stack to the right peg, which is the goal.
- Tap a peg to lift its top disc, then tap the peg where it should go. You can also drag a disc to another peg.
- Move one disc at a time, and only the top disc of a peg.
- A bigger disc can never sit on top of a smaller one.
- When the whole tower is on the right peg, you win.
Discs, par and stars
Choose between 3 and 8 discs. More discs make a much longer puzzle. The counter shows your moves next to the par, which is the fewest moves that can solve it. Solve it at par without using hints for three stars.
Undo takes back your last move, and Hint shows the best next move. Your best result for each size is saved in this browser. Tip: to move a tower of discs, first move everything above the biggest disc to the middle peg, move the biggest disc across, then move the rest on top of it.
How to solve Tower of Hanoi online in the fewest moves
The fewest moves for a tower of n discs is 2n − 1. Every disc you add doubles the work and adds one. These are the par scores in this game:
- 3 discs: 7 moves
- 4 discs: 15 moves
- 5 discs: 31 moves
- 6 discs: 63 moves
- 7 discs: 127 moves
- 8 discs: 255 moves
You can hit par every time with one rule for the smallest disc and one rule for everything else.
- Pick the first move by counting discs. With an odd number of discs (3, 5, 7), move the smallest disc to the goal peg first. With an even number (4, 6, 8), move it to the middle peg first.
- Move the smallest disc every other turn, always in the same direction. Odd towers: left peg to goal, goal to middle, middle back to left. Even towers: left to middle, middle to goal, goal back to left.
- On the turns in between, make the only other legal move. There is always exactly one move that does not touch the smallest disc. Make it.
Keep alternating those two steps and the tower lands on the goal peg in exactly the par number of moves. If you lose your place, use Rehearse a transfer to try the next few moves on a practice copy without spending moves on the real puzzle.
Where the puzzle comes from
The French mathematician Édouard Lucas published the Tower of Hanoi in 1883. He sold it with a story about a temple where priests move 64 golden discs, and the world ends when they finish. At one move per second, 64 discs take 18,446,744,073,709,551,615 moves, which is about 585 billion years.
Tower of Hanoi questions
Can every Tower of Hanoi puzzle be solved?
Yes. With three pegs, any number of discs can be moved, and any legal position can still reach the goal. You cannot get permanently stuck.
How many moves does 8 discs take?
255 at best. At two seconds a move that is about eight and a half minutes without a mistake.
Does this work on a phone?
Yes. Tap a peg to lift the top disc and tap the peg where it goes, or drag it. It runs in the browser, free, with no account.