The Tower of Hanoi: solution and method
By Arnaud, creator of procstd. Updated November 22, 2026.
The Tower of Hanoi can always be solved, and always the same way: you only need one rule for the smallest disc, and to make the only other possible move the rest of the time. Here is the full solution with 3 and 4 discs, the minimum number of moves for every size, and two methods so you are never stuck again: one you can reason through, and one you can apply without thinking.
Try it as you read: play Tower of Hanoi, free and ad-free.
The rules
Three pegs, and a tower of discs stacked from largest to smallest on one of them. You must move the whole tower to another peg, following two rules: you move one disc at a time, the top disc of a pile, and you never put a disc on a smaller one.
In this guide, you start on peg A and finish on peg C; B is the middle peg, the one used as a stopover. In the Tower of Hanoi game, the start and finish pegs change from one game to the next: use the same method and rename the pegs. Discs are numbered from the smallest (1) to the largest.
How many moves does it take?
The minimum for n discs is 2^n − 1: 7 moves for 3 discs, 15 for 4, 31 for 5, 63 for 6, 127 for 7 and 255 for 8. Each extra disc doubles the number of moves, plus one.
The reason is simple. To move the largest disc, all the others must be out of the way, stacked on the middle peg: that is a tower of n − 1 discs to move a first time. The large disc then goes to the finish peg in one move, and the small tower must follow it: n − 1 discs a second time. Hence twice the moves of the smaller tower, plus one.
The smallest disc moves every other turn: 2^(n − 1) times. Disc 2 moves half as often, and so on up to the largest, which moves only once. If you move the large disc twice, you have taken a detour.
The solution with 3 discs
Seven moves: 1. disc 1, A → C; 2. disc 2, A → B; 3. disc 1, C → B; 4. disc 3, A → C; 5. disc 1, B → A; 6. disc 2, B → C; 7. disc 1, A → C.
After the first three moves, discs 1 and 2 are on the middle peg, in the right order: the large disc is free and goes straight to C. The last three moves do the same thing again, from the middle to the finish.
Three discs: after 3 moves, the two small ones are on the middle peg and the large one can go to C.
The solution with 4 discs
Fifteen moves: 1. disc 1, A → B; 2. disc 2, A → C; 3. disc 1, B → C; 4. disc 3, A → B; 5. disc 1, C → A; 6. disc 2, C → B; 7. disc 1, A → B; 8. disc 4, A → C; 9. disc 1, B → C; 10. disc 2, B → A; 11. disc 1, C → A; 12. disc 3, B → C; 13. disc 1, A → B; 14. disc 2, A → C; 15. disc 1, B → C.
Note the first move: with 4 discs, the small disc goes to B, not C. After 7 moves, the three small discs are on B, disc 4 goes to C, and the next 7 moves bring the small tower back on top.
Four discs: after 7 moves, a tower of three is on the middle peg, and disc 4 is free.
Method 1: think in smaller and smaller towers
To move a tower of n discs from A to C: move the top n − 1 discs from A to B, put disc n on C, then move the n − 1 tower from B to C. Each of these smaller towers moves the same way, with an even smaller tower, down to disc 1 on its own, which goes straight there.
This method explains everything, but it means keeping several steps in mind at once when the tower is tall. For 6 or 7 discs, method 2 is more comfortable.
Method 2: the small disc rule
Every other move, move disc 1, always in the same direction, going round: with an odd number of discs (3, 5, 7), it goes A → C → B → A → C…; with an even number (4, 6, 8), it goes A → B → C → A → B…
Between two moves of the small disc, there is only one possible move that does not touch it: between the two other pegs, the smaller of the two top discs goes onto the other one (or onto the empty peg). Play it, then go back to the small disc. The tower reaches C in 2^n − 1 moves, without ever thinking for more than a second.
The only trap is which way to start: remember "odd, straight to the goal; even, via the middle". If the small disc starts the wrong way, the tower ends up on the wrong peg.
A check: parity
In the shortest solution, a disc is never placed directly on a disc of the same parity: an odd disc (1, 3, 5…) only goes on an even one or on an empty peg, and the other way round. If you are about to put disc 3 on disc 5, you went wrong a few moves earlier.
Recovering from a mistake
No need to start again. Look at the largest disc that is not on C yet: all the smaller discs must first go to the third peg, neither its own nor C. That is a smaller tower to move, with the same method. The game's hints follow exactly this reasoning to suggest the best move.
The game's levels
Easy: 4 discs (15 moves at least). Hard, the leaderboard level: 5 discs (31 moves). Expert: 6 discs (63 moves). Hardcore: 7 discs (127 moves), with no hints. The leaderboard counts time: knowing the small disc rule saves seconds on every move.
Your turn
The rules, the levels and the frequently asked questions are on the Tower of Hanoi page. Each level has its own leaderboard.
Play Tower of HanoiOther guides
- How to solve a sudoku: the techniques that work
- Minesweeper: the patterns to know
- How to win at Solitaire: the strategy
- Wordle-style game in French: how to find the word
- 2048: the strategy to win
- How to win at FreeCell
- Nonograms and picross: the method to solve them
- Takuzu (binary puzzle): the techniques to solve it
- How to win at Spider Solitaire
- Killer sudoku: cage combinations and the rule of 45
- Kakuro: sum combinations and the method
- How to solve a Hitori
- Einstein's Riddle: the grid method
- Mahjong solitaire: which tiles to remove first
- How to solve a Slitherlink
- Masyu: the basic techniques
- Traffic Jam: getting the red car out
- Sokoban: the mistakes to avoid
- The 11 nets of a cube
- How to solve a sliding puzzle
- The knight's tour: the method and the solution
- Calcudoku: how to solve a grid
- The fake coin puzzle: the method and the 12 coins solution
- How to win at Reversi: the three rules of strategy
- How to win at Four in a Row: the four rules
- How to solve a Skyscrapers puzzle: reading the clues
- How to solve a Tents puzzle: the method
- Yatzy strategy: which dice to keep and where to score
- Solo Battleships puzzle: the method to find the fleet
- How to solve a Crowns puzzle: the method
- Secret Code: the strategy to crack it in 4 or 5 guesses
- How to solve a Bridges (Hashi) puzzle: the method
- How to solve a Light Up (Akari) puzzle: the method
- How to solve an Islands (Nurikabe) puzzle: the method
- How to solve a Suguru: the method
- How to solve a Mosaic puzzle: the method
- How to solve a Rectangles (Shikaku) puzzle: the method
- How to solve a Dominoes (Dominosa) puzzle: the method
- How to solve a Thermometers puzzle: the method
- How to solve an Inequalities (Futoshiki) puzzle: the method
- How to solve an Aquarium puzzle: the method
- How to win at Oware: the four reflexes