Play the classic Tower of Hanoi puzzle free in your browser. Move disks from one peg to another. No download required.
You have three pegs and a stack of disks of different sizes on the leftmost peg, largest on the bottom. Move all disks to the rightmost peg. You may move only one disk at a time, taking it from the top of any peg and placing it on another. You may never place a larger disk on top of a smaller one. The puzzle is complete when the full stack is rebuilt in the original order on the target peg.
Every Tower of Hanoi solution follows the same recursive structure. To move n disks from peg A to peg C, first move n minus 1 disks from A to B using C as temporary storage, then move the largest disk from A to C, then move the n minus 1 disks from B to C using A as temporary storage. This always produces the minimum number of moves, which is 2 raised to the power n minus 1. For 3 disks that is 7 moves; for 4 disks, 15 moves.
The puzzle was introduced to Western audiences by French mathematician Edouard Lucas in 1883, who framed it with the legend of monks in a temple moving 64 golden disks, after which the world would end. The legend required 2 to the 64th power minus 1 moves, roughly 585 billion years at one move per second. Beyond the legend, the puzzle is a staple of computer science education for demonstrating recursion, and it appears in museums, classrooms, and competitive puzzle circuits worldwide.
The game lets you set the stack anywhere from 3 to 8 disks, and the move counter compares your tally against the optimal total of 2 raised to the n minus 1. Three disks need only 7 moves, but each disk you add roughly doubles the minimum: 4 disks need 15, 5 disks need 31, 6 disks need 63, 7 disks need 127, and 8 disks need 255. Start at 3 or 4 to internalize the pattern, where the smallest disk always returns to the same relative peg every other move. Once your move count consistently matches the optimal, raise the count by one. Jumping straight to 8 disks before the recursive rhythm feels automatic usually produces hundreds of wasted moves and a stalled, half-sorted stack.
The most frequent error is moving the smallest disk in an inconsistent direction. For a clean solve, the top disk should always travel the same way each cycle: with an even disk count it cycles one direction around the three pegs, with an odd count it cycles the other. Players also stall by burying the smallest disk under a larger one mentally, then forgetting it must move first. Another trap is fixating on the target peg too early; the middle peg is essential temporary storage, and refusing to use it forces illegal placements. Since the game blocks any move that puts a larger disk on a smaller one, an illegal click simply does nothing, so wasted clicks signal you are fighting the structure rather than following the alternating small-disk rhythm.
The minimum equals 2 to the power of your disk count, minus one. For the default 4 disks that is 15 moves; for 8 disks it is 255. The counter shows your moves alongside this optimal target, so you can see exactly how efficient your solution was.
Click the peg holding the disk you want to move to select it, then click the destination peg. Only the top disk of a selected peg moves. Clicking the same peg again cancels the selection. You cannot place a disk onto a smaller one.
The game rejects any move that would put a larger disk on top of a smaller one, so nothing happens. It also rejects selecting an empty peg. If a click does nothing, the destination's top disk is smaller than the one you are trying to place.
Yes. Alternate two move types: first move the smallest disk one step in a fixed direction, then make the only other legal move available. Repeat until solved. This simple two-step loop produces the optimal solution for any disk count without any planning.
No. The rules are identical at every disk count: one disk at a time, never a larger disk on a smaller one, rebuild the full stack on the rightmost peg. Only the minimum move total and the time required grow as you add disks.