Joguito

Tower of Hanoi

Move all the disks to another peg, one at a time, without ever placing a larger disk on a smaller one.

Loading the game…
⚠️ Report a bug

Rules

  • Move one disk at a time, always the top one.
  • Never place a larger disk on a smaller one.
  • The minimum number of moves is 2ⁿ − 1: 7 with 3 disks, 15 with 4, 255 with 8.

The trick

To move n disks, move the top n−1 to the spare peg, move the largest to the target, then bring the n−1 back on top of it. It's the classic example of recursion in computer science. Stuck? Tap “Show solution” to watch it solved from your current position.

Frequently asked questions

Where does the Tower of Hanoi come from?

The puzzle was published by the French mathematician Édouard Lucas in 1883, along with a legend about monks moving 64 golden disks.

Can I use the keyboard?

Yes: keys 1, 2 and 3 select the pegs, and Ctrl+Z undoes a move.

You might also like

Also in: Português · Español · 日本語 · Polski · Italiano · Deutsch · Français · Türkçe · Bahasa Indonesia · 한국어 · Nederlands