Explore›Challenges›Tower of Hanoi
V0.133 · EXACT HANOI STATE GRAPH

Tower of Hanoi online

Move one top disk at a time toward the marked target peg, never placing a larger disk on a smaller one. This version starts from generated legal states rather than repeating only the textbook full stack, and every bundled source carries an independently verified shortest-path distance.

3-peg + 4-peg playExact optimal movesLocal Clean/Assisted records

More than the familiar full-stack example

The classic puzzle is often introduced with every disk stacked on one peg. That is useful for learning the rule, but a generated mid-state asks a different planning question: from exactly where the disks are now, which legal move keeps the shortest finish available?

Easy · 3 pegs, 5 disks

Shorter generated states with exact distances from 10 to 18 moves. The three-peg graph is constrained enough to make the optimal structure visible while still requiring deliberate sequencing.

Standard · 4 pegs, 7 disks

Four pegs create more legal choices. The source bank selects states whose verified minimum is 18–22 moves and filters out extremely branchy positions so each puzzle still rewards planning.

Challenge · 4 pegs, 8 disks

Deeper states with 27–29 verified moves remaining. More disks and legal destinations make casual local choices expensive even though an exact finish remains known.

What “optimal moves” means here

The displayed par is not estimated from a formula and it is not copied from the source bank without checking. During release verification, a separate breadth-first search rebuilds the complete legal state graph for each peg-and-disk configuration. The target state — every disk on the target peg in legal size order — is distance zero. The verifier then measures the shortest number of legal edges from every reachable state back to that goal.

That matters because these puzzles begin from scrambled legal positions. The familiar three-peg formula for moving a full tower does not directly tell you the shortest finish from an arbitrary arrangement. The game therefore treats the current peg assignment itself as the state. After every move, it can report the exact remaining distance from that new state.

The monitor also shows detour overhead. At the start, moves made plus optimal moves remaining equals the source par. If a move keeps that total unchanged, an optimal finish is still possible. If the total increases, the game can show exactly how many extra moves have become unavoidable from the route taken so far. That gives a clearer planning signal than a timer alone.

Controls built for mouse, touch and keyboard

On pointer devices, drag the top disk toward a destination peg or tap a source peg and then the destination. Lower disks cannot be moved directly because they are covered by smaller disks. Illegal destinations are rejected instead of silently changing the board.

Keyboard play uses the number keys to choose pegs directly. Left and Right move the focus between pegs, while Enter or Space selects the focused peg. Undo and Redo let you inspect a detour without abandoning the puzzle. Restart returns to the same verified source state, while Fresh puzzle selects another deterministic Practice seed.

Pause freezes interaction and elapsed time. Check does not reveal a route; it independently reports the exact number of moves remaining and whether par is still achievable. Verified Hint is stronger: it examines the legal neighbors of your current state and applies one whose exact distance is one lower. Because Check and Hint expose solver information, they mark the run Assisted rather than quietly inflating a Clean record.

Project-local source and release verification

The frozen bank contains 60 generated sources: 20 Easy, 20 Standard and 20 Challenge. A source records the peg count, disk count, starting assignment, target peg, exact shortest distance and number of shortest paths. The generator excludes trivial positions and avoids sources that are merely peg-renamings of another source.

Release QA does not trust those stored numbers. Its independent solver rebuilds legal moves from the disk-size rule, reconstructs the complete BFS distance table, recomputes shortest-path counts, and checks every stored source. It also checks every peg permutation, producing 1,080 verified transformed boards before seeded Practice and Daily sampling are tested.

Nothing depends on a remote puzzle API, account or server-side solver. The bank, exact state engine, autosave and records are browser-local. That makes a Practice seed replayable and lets the same package work offline through the project PWA once deployment is eventually approved.

Practice versus Daily Hanoi

How to improve without memorizing a route

A useful first habit is to stop treating every legal move as equally good. Before moving, identify which disks are actually exposed and ask which destination preserves access for the next larger disk. The live remaining-distance number makes this measurable: if it drops by one, the move lies on at least one shortest route from the current state.

When the distance rises, use Undo and inspect why. Often a small disk has occupied the only useful landing peg or a medium disk has been moved away from the structure needed for a larger transfer. Standard and Challenge deliberately offer more empty space, so planning the role of spare pegs matters more than simply making the only legal move.

Try to solve Clean before using Check or Hint, then replay the same seed Assisted if you want to study the exact route. Because the source remains stable, you can compare your own first attempt with the verified par without turning a hint-assisted solve into a misleading personal best.