What Is Tower of Hanoi?
A free online Tower of Hanoi puzzle game. Challenge yourself with 3-7 disks and move the entire stack from peg A to peg C. You can only move one disk at a time and you can never place a larger disk on a smaller one. Use the Auto Solve feature to watch the optimal recursive solution in action, perfect for understanding algorithmic thinking.
The Tower of Hanoi is a classic mathematical puzzle invented by French mathematician Edouard Lucas in 1883. It consists of three pegs and a stack of disks of different sizes. The objective is to move the entire stack from the first peg to the last peg, following three simple rules: only one disk can be moved at a time, only the top disk on a peg can be moved, and no larger disk may be placed on a smaller one.
Start by selecting the number of disks (3 to 7). More disks exponentially increase the difficulty — the minimum number of moves required is 2^n - 1. With 3 disks, you need at least 7 moves. With 7 disks, you need 127 moves. The puzzle is a perfect demonstration of recursive thinking: to move n disks, you first move n-1 disks to the auxiliary peg, then move the largest disk, then move the n-1 disks on top of it.
Click a peg to pick up the top disk, then click another peg to place it. The game enforces the rules visually: if you try to place a larger disk on a smaller one, the move is rejected. The move counter tracks how many moves you have made, displayed against the minimum possible moves.
The Auto Solve feature demonstrates the optimal recursive solution. Watch as the algorithm efficiently moves all disks to the target peg in exactly 2^n - 1 moves. Each move is animated so you can study the pattern. The visual win detection triggers congratulations when you complete the puzzle.