Tower of Hanoi
Move the tower. One stone at a time.
- Genre
- Puzzle, Brain Teaser
- Controls
- Touch: tap a peg to lift its top stone, then tap another peg to set it down (or drag the stone)
Mouse: click or drag
Keyboard: 1, 2, 3 pick and drop, Z or Ctrl+Z undo, H hint, R restart
About Tower of Hanoi
Tower of Hanoi, also called Hanoi Tower or Towers of Hanoi, is the classic stacking puzzle, set in a quiet stone garden at dusk. Smooth river stones sit on the left of three polished wooden pegs, biggest at the bottom. Move the whole stack to the right peg, one stone at a time, and never put a bigger stone on a smaller one. Start with 3 stones and climb to 8, chasing par and three stars on every stack, try today's Daily Stack, or switch to Zen for endless calm with no counters at all. Every stone lands with a soft click and a ripple in the raked sand. It's free, there are no ads, and it starts the moment you tap.
How to play Tower of Hanoi
The goal is to move the whole tower of stones from the left peg to the right peg.
- Tap a peg to lift its top stone, then tap another peg to set it down. You can also drag a stone from peg to peg.
- Move only one stone at a time, and only the top stone of a peg.
- Never put a bigger stone on top of a smaller one.
The fewest moves is 2ⁿ − 1
With n stones the shortest solution takes 2ⁿ − 1 moves: 7 moves for 3 stones, 15 for 4, 31 for 5, 63 for 6, 127 for 7 and 255 for 8. Each extra stone doubles the work plus one, because you must move the smaller tower out of the way, move the biggest stone once, then move the smaller tower back on top of it.
Tips
Think about the biggest stone first: before it can move, every other stone has to be stacked on the middle peg. The smallest stone moves on every other turn and always travels in the same direction around the pegs: with an odd number of stones it goes left, right, middle, left; with an even number left, middle, right, left. Stuck? Tap Hint to see the next best move from wherever you are, even after a few mistakes.