Tower of Hanoi — full guide
Version 1.0.0 · A little balance · Catalogue 51
Three pillars. One quiet challenge. Move the complete stack from the left peg to the right peg, one disc at a time. There is no timer.
Start a game
The game opens with 4 discs on peg 1 / START. Peg 2 / REST is the spare peg; peg 3 / HOME is the destination. Use the numbered disc buttons to choose 3, 4, 5, 6 or 7 discs. Choosing a size immediately starts a fresh stack of that size and clears the move count and undo history.
The smaller the number printed on a disc, the smaller the disc. All discs begin ordered from largest at the bottom to smallest at the top. The colours and numbers help identify them; colour alone is never needed.
The exact rules
- Move only the top disc from a peg.
- Move one disc at a time to another peg.
- A disc may go on an empty peg or on a larger disc. A larger disc cannot sit on a smaller disc.
- Finish when every disc is on peg 3 / HOME. A complete tower on the middle peg is not the goal.
A legal move adds one to MOVES. Selecting a disc, cancelling a selection, asking for a hint or attempting an illegal move adds nothing. An illegal placement leaves the selected disc available so you can choose another destination.
Touch, mouse and keyboard
| Action | Control |
|---|---|
| Select a source | Tap or click the peg with the disc you want to move. Only its top disc lifts and receives a ring. |
| Place the disc | Tap or click the destination peg. The whole peg is the target. |
| Cancel selection | Tap the selected peg again, or press Escape. |
| Use the numbered pegs | Press 1, 2 or 3 to select a source, then press the destination's number. |
| Undo | Tap Undo or press U. |
| Get a hint | Tap A little hint. It selects the source; tap the named destination to make the move. |
| Start again | Tap Restart, or choose a disc count for a fresh stack. |
| Use ordinary button navigation | Use Tab to reach a button and Enter or Space to activate it. |
If keyboard shortcuts seem unresponsive inside another website, click or tap inside the game first so its frame receives your keys. A status line explains the selection, move, hint or invalid placement. Empty pegs cannot be selected as a source.
A worked 3-disc finish
Choose 3 in DISCS. Follow these seven moves in order. Disc 1 is the smallest and disc 3 the largest.
| Move | Disc | From → to |
|---|---|---|
| 1 | 1 | Peg 1 → peg 3 |
| 2 | 2 | Peg 1 → peg 2 |
| 3 | 1 | Peg 3 → peg 2 |
| 4 | 3 | Peg 1 → peg 3 |
| 5 | 1 | Peg 2 → peg 1 |
| 6 | 2 | Peg 2 → peg 3 |
| 7 | 1 | Peg 1 → peg 3 |
With keys, the source–destination pairs are 1–3, 1–2, 3–2, 1–3, 2–1, 2–3, 1–3. The result reads “Beautifully balanced.” with 7 moves and “A perfect path.”
Strategy and the minimum
Think about freeing the largest disc. First move the smaller tower to the spare peg, then move the largest disc to HOME, then move the smaller tower onto it. Apply the same idea to each smaller tower.
The minimum for a fresh stack is 2ⁿ − 1, where n is the number of discs:
| Discs | Fresh-start minimum |
|---|---|
| 3 | 7 moves |
| 4 | 15 moves |
| 5 | 31 moves |
| 6 | 63 moves |
| 7 | 127 moves |
MINIMUM stays at this fresh-start benchmark throughout the game. It does not display the number of moves remaining, and it does not change after a detour. Finishing above it is still a successful finish.
Hints and undo
A little hint works from the actual arrangement on the board. It finds a legal next step toward HOME even after you move discs away from the initial route. The status line names the disc, source and destination. The source is already selected: tap the destination to follow it. Tap the source again or press Escape if you want to cancel instead. A hint does not move a disc automatically and does not add a move.
Undo returns the board to the position before the last legal move and subtracts one from MOVES. You can undo repeatedly while history remains. Undo is unavailable at a fresh start. It also works after completion, returning the game to play. There is no separate penalty or assisted-result label for using hints or undo; “A perfect path” compares the displayed move count with the fresh-start minimum.
Completion and replay
When the last disc reaches HOME, the completed tower stays in full colour. The result shows the disc count and your moves. If your count equals the minimum, it adds “A perfect path.” Otherwise it states the fresh-start minimum. The pegs and hint button stop accepting play while completed.
Use Restart to replay the current size, choose a different disc count to begin that size, or use Undo to revisit your last move. Restart and changing size clear the undo history. There is no score table, time limit or persistent best result.
Full guide, installation and offline play
Full guide opens this guide in a new tab, leaving the game tab or embedded frame in place. The printable HTML guide includes a Print guide button; your browser's print dialog can print it or save it as a PDF where supported.
Open the game as its own page over HTTPS, or on localhost when testing. Use Install if the browser offers an installation prompt. If no prompt is supported, the game explains the browser-menu route; look for an install or add-to-home-screen command in your browser. Availability depends on the browser and device. You can always play in an ordinary browser tab.
Load the standalone game online first and allow it to finish preparing its local cache. The game and full guide can then load offline in that same browser and origin while its cached data remains available. The game uses a cache scoped to its own folder; it does not remove unrelated games' caches. Opening it at a different address requires a fresh online visit. Browser data clearing removes the cached files too.
Inside an embedded game, Install asks the host website to handle installation. If the host does not handle it, the game shows instructions for opening the standalone page and using the browser menu. An embedded game does not register its own service worker, so use the standalone page for this game's independent offline installation.
Progress lasts for this session
Board position, disc count, undo history and result live only in the current page. Reloading, closing or reopening starts a fresh default 4-disc game. Installation and offline caching save the application files, not your puzzle progress. Each embedded instance has its own independent session; removing and reconnecting one starts it fresh.
Troubleshooting
| What you see | What to do |
|---|---|
| “A larger disc cannot sit on a smaller one.” | Choose an empty peg or a peg with a larger top disc. The selected disc is still selected. |
| An empty peg cannot be selected | Select a peg that holds a disc, then choose the empty peg as its destination. |
| A hint appears but nothing moves | The source is selected. Tap or key the destination named in the hint. |
| Undo is disabled | There is no earlier legal move in this session. Selection and invalid attempts do not enter history. |
| Pegs do not respond after the finish | The puzzle is complete. Use Undo, Restart or a disc-count button. |
| Keyboard shortcuts do not reach an embedded game | Click or tap inside the game frame before pressing 1/2/3 or U. |
| The offline page or guide does not load | Visit the standalone page online again in the same browser, allow caching to finish, then retry. Private browsing or cleared site data may prevent retention. |
| Install offers browser instructions rather than a prompt | Use the browser's install/add-to-home-screen control if available, or continue in the tab. Embedded installation belongs to the host website. |
| The game is blank when opened as a local file | Serve the complete public folder with an HTTP server. JavaScript modules are not intended to run from a file URL. |
| Your earlier puzzle is gone after reload | This is expected: the game does not save progress. |
Limits and provenance
This is a local solo Tower of Hanoi game with 3–7 discs and HOME fixed on the right. It has no automatic solver animation, timer, multiplayer, account, payments, saved history or remote service. Hints recommend one move at a time; you make every move yourself.
The code, instructions, brass pegs, coloured-disc shading and sun-arch illustration are original. Artwork is drawn with local CSS, with no downloaded assets, runtime CDN or remote font. Available system Avenir/Trebuchet and Georgia fonts provide the typography. Reduced-motion preferences disable the short transitions. The game retains the accepted rules, artwork and interaction model in this version.