Tower of Hanoi is the classic three-peg puzzle. A stack of rings sits on the left peg, largest at the bottom, and you must rebuild it on the right peg. You move one ring at a time and may never place a ring on a smaller one. It is worth playing because it is one of the clearest examples of recursion you can hold in your hands, and Douile’s version shows your moves beside the best possible total.

Rules of the Pegs

Lift the top ring from any peg and drop it on another. It can land on an empty peg or on a larger ring, never on a smaller one. The lifted ring floats above the selected peg, so you can see where it will go.

You begin with three rings. The plus and minus icons change the count, with three as the minimum, and each change starts a fresh puzzle. The counter shows moves made over the minimum, for example 10/7. When the stack lands on the right peg, the board zooms briefly to mark the finish.

Tower of Hanoi Controls

Controls for Tower of Hanoi
ActionKeyboardMouseTouch
Pick up or drop a ringSpace, Enter, Up/Down arrows, or W/SClick a pegTap a peg
Move the selection between pegsLeft/Right arrows or A/D——
Restart the puzzleRClick the circular arrows iconTap the circular arrows icon
Add or remove a ring—Click the plus or minus iconTap the plus or minus icon
Watch the puzzle solve itself—Click the play icon (click again to stop)Tap the play icon (tap again to stop)

Why It Matters in Math

To move n rings, you first move the top n minus 1 rings out of the way, then move the biggest ring, then move the n minus 1 rings back on top. That is a recursive rule: the big problem is built from a smaller copy of itself. Count the moves and you get M(n) = 2 × M(n − 1) + 1, which works out to 2 to the n, minus 1. Computer science classes use this puzzle to teach exactly that idea.

There is also a neat pattern in the moves. The smallest ring moves every other turn, always cycling in the same direction.

How to Hit the Minimum

  • Check odd or even. With an odd ring count, the smallest ring’s first move is to the right peg. With an even count, it goes to the middle.
  • Alternate. Move the smallest ring, then make the only other legal move, then the smallest ring again.
  • Think in stacks. Treat the top few rings as one block that must be moved before the next big ring.
  • Watch the solver once on four or five rings, then reset and copy the rhythm.

Before You Press Play

Keyboard, mouse and touch all work, and a three-ring puzzle takes under a minute. Five or six rings is a proper test of focus. For more number patterns, try Light Switch Grid or Fifteen Slide.

Tested and updated: