Skip to content
STEM Little Explorers
HR
The Tower of Hanoi puzzle

Tower of Hanoi: How to Play, Solve & the Minimum Moves

Iva Leder
Iva Leder
13 min read

Originally published June 25, 2020

Free summer e-book

Summer of curiosity

Download freeNo sign-up
  • Age:5+
  • Time:30 min
  • Difficulty:Easy
  • Mess level:Low
  • Supervision:Yes

🎮 Play as you read

This guide has a playable Tower of Hanoi built in - scroll down to try it with 3 to 6 disks. Prefer a full page? Open the Tower of Hanoi puzzle tool.

The legend goes that there is a temple in Asia where the monks have been solving the Tower of Hanoi puzzle with 64 disks since the beginning of the time. According to this legend, when the monks finish moving all the pieces, the world will end.

Tower of Hanoi - Origin of the Name

This popular puzzle is known by a few different names. Sometimes it’s called Lucas’ Tower in honor of its inventor French mathematician Édouard Lucas, who invented it in 1883.

It’s also referred to as the Tower of Brahma because some believed that the temple from our legend is located in India and that monks are actually Brahmin priests.

The third and most popular name is the Tower of Hanoi. The name refers to a place from the legend, it’s said that the tower is in the capital city of Vietnam, Hanoi.

How does the Tower of Hanoi Puzzle work

You start with the three spots (most often wooden sticks) and a certain number of disks (pieces) stacked on the first spot.

All disks are in different sizes and stacked in a way that a smaller disk is on top of the larger. The goal is to move all the disks from the first spot to the third spot so they are stacked in the same way as in the beginning. However, there are a few rules we must obey.

The Tower of Hanoi: disks stacked from largest to smallest, waiting to be moved.

The goal of Hanoi Tower is to get all discs from Start to Goal following specific rules.

First is that the disks can be moved only one at the time. Second is that only the disk at the top can be moved on another spot. And the third is that the disk can’t be moved on top of the smaller disk, just on top of the larger disk or on the empty spot.

You can play with any number of pieces and it’s getting progressively harder with each new piece. An additional challenge is to solve the puzzle in the minimum number of moves.

Give it a go right here! Start with 3 disks and work your way up:

Disks
Moves: 0
Fewest possible: 7

Tap a peg to pick up its top disk, then tap another peg to drop it. Move the whole stack to the last peg. Rule is that a bigger disk can never sit on a smaller one.

Advertisement

Hanoi Tower Math

Did you already try to solve the Tower of Hanoi and it looks simple? Try to solve the puzzle with 3 pieces in 7 moves. Or with 4 pieces in 15 moves. With 5 pieces, the minimum number of moves is 31! And so on...

For every new piece we add, the minimum number of moves doubles (+ 1 on top of that)! The formula used to calculate this is 2^n − 1, where n is the number of pieces used.

For example:

1 Disk: 2^1 - 1 = 2 - 1 = 1 move 2 Disks: 2^2 - 1 = 4 - 1 = 3 moves 3 Disks: 2^3 - 1 = 8 - 1 = 7 moves 4 Disks: 2^4 - 1 = 16 - 1 = 15 moves 5 Disks: 2^5 - 1 = 32 - 1 = 31 moves ...

Do you remember our monks who are trying to solve the puzzle with 64 pieces? They would need 2^64 − 1 moves at a minimum. That’s 18446744073709551615 moves! Can you even read that number? If they do one move per second and do every move in the correct order, they would still need 585 billion years to solve the puzzle! So we don’t really need to worry about that end of the world thing anytime soon.

Now you’ll learn how to make your own simple Hanoi Tower and the algorithm for how to solve it. First, try to solve it yourself, the beauty of the puzzles is in struggling before coming to that aha moment.

Solving the tower with 3 disks takes 7 moves. What's the minimum number of moves for 4 disks?

Make your prediction, then tap an answer to check!

Materials needed for Hanoi Tower

A homemade Hanoi Tower needs just cardboard, scissors and something for the rods.

To make our Tower of Hanoi, we will need Styrofoam or Cardboard, compass and a ruler.

  • Styrofoam or Cardboard. We will use Styrofoam (Cardboard can be a good replacement too) to make our pieces for Hanoi Tower. You can make as many pieces as you want, just make sure they are in different sizes.
  • Compass. We will use a compass to draw circles on our styrofoam or cardboard so we can precisely make shapes that are different in size.
  • Ruler. We will use a ruler to measure the different radius of our pieces. Take the ruler and compass, and measure a 1 cm radius. Draw the circle on styrofoam or cardboard. Then measure 2 cm radius and repeat the process. This way we can create as many shapes as we want by increasing the radius by 1 cm.
  • Scalpel or Scissors. We will use a scalpel or scissors to cut out our shapes. Scalpel will be better if we are using styrofoam and scissors if we are using cardboard.
  • Markers. This is a bonus and we will use it to decorate our shapes to make them more interesting and to distinguish them better.
  • A4 or bigger paper. Instead of wooden sticks, we can use plain paper and draw 3 fields. The goal is the same: move all pieces from the first field to the third field.

How to make your own easy Hanoi Tower

For a step by step video guide on how to make the Tower of Hanoi, check out the video at the beginning of the article or continue reading…

We will show you how to make the Hanoi Tower with 5 pieces. But you can easily follow the same steps to create more or fewer pieces for your Hanoi tower.

  • Take the compass and measure the radius of 5 cm with the help of a ruler. Draw a circle on the styrofoam or cardboard.
  • Cut the circle from styrofoam or cardboard using the scalpel or scissors.
  • Now repeat the process but this time measure the radius of 4 cm. Do the same procedure making more circles with 3 cm, 2 cm, and 1 cm radius. This will give you 5 pieces for our Hanoi Tower. If you want more, repeat with circles with a radius of 6+ cm.
  • Use markers to color your pieces so they are more recognizable.
  • Put a piece of A4 paper horizontally and divide it into 3 equal columns so we have enough room for our pieces.
  • Label first column start and the third goal.
  • Play the Tower of Hanoi! Can you move your pieces from start to goal in the minimum number of moves? Have fun!

How to solve Tower Of Hanoi (Algorithm for solving Tower of Hanoi)

The algorithm of a tower of Hanoi is actually quite simple and consists only of 3 steps which are repeated until the puzzle is solved.

We will label our positions as A (start), B (middle), and C (goal).

The algorithm depends on the starting number of pieces. If there is an even number of pieces we use different sequences than when there is an odd number.

A three-disk tower is the perfect size for learning the solving algorithm.

To solve the Hanoi Tower with 3 disks, we will need a minimum of 7 moves.

If we have even number of pieces

  1. make the legal move between positions A and B
  2. make the legal move between positions A and C
  3. make the legal move between positions B and C
  4. Go to step 1 and repeat steps 1, 2, and 3 until you complete the puzzle.
Advertisement

If we have an odd number of pieces

  1. make the legal move between positions A and C
  2. make the legal move between positions A and B
  3. make the legal move between positions B and C
  4. Go to step 1 and repeat steps 1, 2, and 3 until you complete the puzzle.

Legal move - piece can go only on a bigger piece or on the empty spot.

Although it seems very abstract and it’s hard to visualize, when you start moving the pieces you will appreciate this algorithm. We say it's an algorithm because it’s a recipe to solve this problem for any number of inputs (pieces) in the minimum number of moves. Try with 6 or 7 pieces and see that it still works!

The Tower of Hanoi pattern (the trick)

Play a few rounds and you start to feel a pattern hiding inside that algorithm. It's worth naming, because once you see it the puzzle stops being guesswork and becomes something you can almost do on autopilot. Here is the whole trick in three lines (the pieces are called disks or discs, both work):

Every second move is the smallest disc. Move the smallest one, make the only other legal move on the board, move the smallest one again, and keep alternating until you're finished.

The smallest disc always travels in the same direction. It never doubles back. Which direction depends on how many pieces you started with:

  • Odd number of discs (3, 5, 7): send the smallest one A → C → B → A → C → B and so on.
  • Even number of discs (4, 6): send the smallest one A → B → C → A → B → C and so on.

The in-between moves make themselves. When it isn't the smallest disc's turn, there is only ever one legal move that doesn't involve it. You never have to choose. Just find it and play it.

That's all there is to it. Follow the pattern without a single wrong turn and you will move all the discs to tower 3 in the minimum number of moves every time:

DiscsMinimum moves
37
415
531
663
7127

If you lose your place, don't restart. Look at which peg the smallest disc sits on, remember which way it was travelling, and pick the pattern back up from there.

What will you develop and learn by solving Hanoi Tower

  • Math skills, Algorithmic thinking, and approach to solving the problem in the most efficient way.
  • Technology skills. All computer programs are based on algorithms.
  • Logic skills.

Key takeaways

  • The Tower of Hanoi is a classic puzzle: move a stack of disks from the first peg to the third, one disk at a time, never placing a bigger disk on a smaller one.
  • It was invented by Édouard Lucas in 1883 and comes wrapped in a legend of monks moving 64 golden disks.
  • The minimum number of moves is 2ⁿ − 1 (3 disks = 7, 4 = 15, 5 = 31), so each extra disk roughly doubles the difficulty.
  • There's a simple repeating algorithm to solve it - a great first taste of the recursive, step-by-step thinking used in programming.
  • You can make one from cardboard or styrofoam discs, and adjust the difficulty just by changing the number of disks, so it suits any age.

Tower of Hanoi - Frequently Asked Questions

What is the minimum number of moves in the Tower of Hanoi?

The minimum is 2^n − 1 moves, where n is the number of disks: 3 disks take 7 moves, 4 disks take 15, 5 disks take 31, 6 disks take 63, and 7 disks take 127. Every extra disk roughly doubles the number of moves needed.

How do you move all the disks to tower 3?

Only ever place a smaller disk on a bigger one, and follow the alternating pattern: with an odd number of disks, make the first move to the target peg; with an even number, make the first move to the spare peg. Then keep cycling the smallest disk in the same direction and making the only other legal move in between - the full algorithm is explained step by step above.

What is the pattern for solving the Tower of Hanoi?

Every second move is the smallest disc, and it always travels in the same direction, never doubling back: with an odd number of discs it cycles start → goal → middle, with an even number it cycles start → middle → goal. On every move in between there is only one legal move that doesn't involve the smallest disc, so you simply play it. Alternating those two steps solves the puzzle in the minimum number of moves.

Why is it called the Tower of Hanoi?

Its inventor, French mathematician Édouard Lucas, published the puzzle in 1883 together with a legend about a temple where monks move 64 golden disks; the tower of the legend was said to stand in Hanoi, Vietnam. The puzzle is also known as Lucas' Tower (after its inventor) and the Tower of Brahma.

Is the Tower of Hanoi good for kids?

Yes - it works from preschool age upward because difficulty scales with the number of disks: start with 3 disks (7 moves) for young children and add disks as they improve. It trains planning, patience, and the same recursive thinking used in programming.

We hope you enjoyed making and then solving the Tower of Hanoi! If you want more fun ways to learn math, improve logical skills or activities with numbers, check out these articles:

Share this article:
Iva Leder
Iva Leder

Psychologist

The founder of STEM Little Explorers and a lifelong lover of learning, she believes that education has the power to change lives. Always searching for more creative and effective ways to teach, she sees unlimited potential in every child. Her mission is simple: to help unlock that potential by finding the approach that works best for each unique learner.

More articles by this author →

Enjoyed this article?

Subscribe to get new posts straight to your inbox.

No spam, unsubscribe anytime.

Related Posts