Tower of Hanoi
Move the whole tower from peg A to peg C, one top disk at a time. Play at your own pace, review the recursive solution, and challenge someone to match or beat your move count.
Move the tower from A to C
Move only the top disk, one at a time. A larger disk cannot sit on a smaller disk. Select a source peg, then its destination; select the source again to cancel. With the board focused, keys 1, 2 and 3 select A, B and C. Changing disk count or restarting resets the run.
Select any nonempty peg to begin a move. Disk 1 is the smallest. There is no time limit.
Undo/redo preserve up to 10,000 moves. Exploring the solution preserves your play position but marks the current run assisted. Restart for a fresh shareable attempt.
Your applied moves
No moves yet. Your first legal move will appear here.
Why is the minimum 2ⁿ − 1?
Before the largest disk can move from A to C, all 2 smaller disks must move to B. Move the largest disk once, then move those smaller disks from B to C. The same problem repeats with one fewer disk.
M(0) = 0; M(n) = 2 × M(n − 1) + 1 = 2ⁿ − 1. For 3 disks, that is 7 moves. This bound is for the standard three-peg start and goal.
Standard three-peg Tower of Hanoi with one disk moved at a time. The minimum from the starting tower is 2^n − 1 moves. Shared scores are self-reported; solution review and undo mark a run as assisted. Game state stays in this page’s memory. Challenge analytics record the tool and fixed configuration seed, never the move history.
Common questions
- What are the rules of Tower of Hanoi?
- Move all disks from peg A to peg C using peg B as a spare. Move only one top disk at a time. Never put a larger disk on a smaller disk. Select the source peg, then the destination; select the source again to cancel.
- How many moves are required?
- The minimum from the standard starting tower is 2^n − 1 for n disks. Three disks need seven moves; twelve need 4,095. This result applies to three pegs, not a generalized puzzle with more pegs.
- How does the recursive solution work?
- Move the smaller n−1 disks from A to B, move the largest disk from A to C, then move the smaller tower from B to C. Each smaller tower repeats the same process. Explore solution offers playback, single-step controls, speed selection, a position scrubber and the full move trace.
- Does solution review change my game?
- Your play position is preserved separately from the solution demonstration. Opening solution review marks the current play run assisted. Returning to Play puzzle restores your position. Restarting creates a fresh manual run. Playback pauses when the page is hidden and stops when you pause, step, scrub or leave review.
- Can I undo and export moves?
- Undo and redo retain up to 10,000 moves, and mark the run assisted. Making a new move after undo replaces the undone branch. Move-history CSV contains all currently applied moves; the solution CSV contains all 2^n−1 moves, regardless of the visible page.
- How do shared challenges work?
- Complete a manual run without undo or solution review to copy a challenge link or download a result card. The recipient gets the same disk count and standard starting tower, with your self-reported move count. Fewer moves is better; a minimum score invites a tie. Completed recipients can share their own result. Links contain only configuration and score, never names or move history.
- Is there a timer or saved progress?
- There is no time limit. Game state stays in page memory and is not automatically saved, so download move history before leaving if needed. Keyboard users can focus the peg buttons and press Enter or Space, or use 1, 2 and 3 while the board is focused.
Standard three-peg Tower of Hanoi with one disk moved at a time. The minimum from the starting tower is 2^n − 1 moves. Shared scores are self-reported; solution review and undo mark a run as assisted.