Skip to main content

Tower of Hanoi

One disk at a time. Build the whole tower on C without placing a large disk on a smaller one.

Moves0

Round minimum7

Remaining minimum 7

Preparing the puzzle…

About Tower of Hanoi

Tower of Hanoi is a planning puzzle played on three pegs with disks of different sizes. You repeatedly make space for a larger disk by moving the smaller tower somewhere else. The goal is the complete stack on C.

This independent browser version has eight disk counts from 3 to 10 and two starting modes. It uses original code and illustrations. No download, account, numbered level campaign or time limit is required.

How to play Tower of Hanoi

  1. 01Choose a peg to pick up its top disk, then choose another peg to move it. Only one disk moves at a time.
  2. 02A disk may go onto an empty peg or a larger disk. Bigger disks cannot be placed on smaller ones.
  3. 03Move every disk onto peg C to solve the puzzle. There is no countdown or move limit.
  4. 04Classic starts with the whole tower on A. Scrambled starts spread the disks across the three pegs, with a different shortest solution.

Tower of Hanoi controls

Mouse or touch
Tap the source peg, then the destination. The selected top disk lifts slightly. Tap the source again or press Escape to cancel. An empty source or a larger-on-smaller move shows a message without moving anything.
Keyboard
Tab to a peg; Left and Right change peg focus, Home and End reach A and C. Enter or Space chooses the focused peg. Number keys 1, 2 and 3 choose A, B and C while focus is in the board.
Undo, hint and restart
Undo reverses a move, up to the most recent 2,048. Hint shows the next optimal transfer but never performs it. Restart returns to this round’s original arrangement. New puzzle creates a mixed start; changing the disk count or mode starts a fresh round.

Tower of Hanoi: levels and progress

These are repeatable configurations rather than numbered levels. Classic puzzles use 3–10 disks. Their exact minimum is 2ⁿ − 1: 7, 15, 31, 63, 127, 255, 511 and 1,023 moves respectively.

Scrambled puzzles start with disks on more than one peg, and can require fewer moves. The round minimum is calculated from that starting arrangement, while Remaining shows the exact shortest distance from the current position. A detour can increase it.

Your current arrangement, move count and recent undo history save locally when storage is available. They are not synced to other devices. Reloading a solved puzzle keeps it solved; Restart lets you play again.

Tower of Hanoi tips and strategies

Work backwards from the largest disk

If the largest disk is not on C, all smaller disks must first gather on the third peg. Move the largest disk onto C, then move the smaller tower on top. Repeat this same idea at the next smaller scale.

Read the minimum correctly

The classic 2ⁿ − 1 formula starts with a whole tower on one peg. It is not the answer for every scrambled position. Compare your moves with this round’s minimum, and use Remaining to judge the current position.

Try before asking for a hint

Think through the next large-disk transfer. If you get stuck, reveal one next step, carry it out yourself, then try the next decision without a hint. Undo is available while the puzzle is unfinished.

  • Before moving the largest disk, gather the smaller disks on the spare peg.
  • Use the remaining minimum to see whether a move brought you closer; a hint only shows the next move.

Tower of Hanoi FAQ

What are the Tower of Hanoi rules?

Move only the top disk, one at a time. Put it on an empty peg or a larger disk. Solve the puzzle by collecting every disk on peg C.

What is the minimum number of moves for 7 disks?

A classic seven-disk tower needs 2⁷ − 1 = 127 moves. A scrambled seven-disk position has its own minimum, displayed for that arrangement.

Can I lose by exceeding the minimum?

No. The minimum is a target for efficient play, not a move limit. You can take detours, undo recent moves or restart. All legal arrangements can reach the goal.

Does the hint solve the puzzle for me?

No. It identifies one legal move on a shortest path. You still choose the two pegs yourself; simply viewing a hint does not add a move.