Skip to content

Tower of Hanoi

puzzles

Level 2 of 3

Also called Towers of Hanoi, Tower of Brahma and Lucas' tower.

test yourself

Six questions, four to pick from and two for paper.

fresh numbers: the questions a run answers, asked again on new numbers

choose one

question 1

How many moves does the method make for 6 discs?

the answer, and why

the answer is D

Twice the moves for 5 discs, 31, plus 1, which is 63. That is 64 less 1.

if you chose another

  • That is 2 to the power 6. The method makes one move fewer.
  • That is 6 times 6. The moves double with each disc.
  • That is twice 31, without the biggest disc's own move.

question 2

With 6 discs, how many times does disc 1, the smallest, move?

the answer, and why

the answer is B

Each smaller disc moves twice as often as the next bigger one. Disc 6 moves once, discs 5 to 2 move 2, 4, 8 and 16 times, and disc 1 moves 32 times.

this tests where the formula comes from, on the learn page

if you chose another

  • That is disc 2.
  • That is disc 6, the biggest.
  • That is every move, of all six discs.

question 3

With 3 discs, where does the method move disc 1 on its first move?

the answer, and why

the answer is B

The first three moves take discs 1 and 2 to B. For disc 2 to land on B, disc 1 must be out of the way on C first.

if you chose another

  • It starts on A, so that is no move.
  • Then disc 2 could only go to C, and the two would end on C, not B.
  • Disc 1 is on top, so it is the only disc that can move first.

question 4

One more disc is put at the bottom of the tower. What happens to the moves?

the answer, and why

the answer is B

The old tower moves aside, the new disc moves once, and the old tower moves back on top. So twice the moves, plus 1. For 3 discs to 4, 7 becomes 15.

this tests where the formula comes from, on the learn page

if you chose another

  • The old tower moves twice, not once.
  • The new disc moves too, once.
  • For 3 discs to 4, that would give 9, not 15.

pen and paper

question 5about 6 minutes

Move 3 discs from A to C by hand, as the method does.

  1. Write every move as disc, from and to.
  2. How many times does each disc move?
  3. Check the total against 2n−12^n - 1.
a hint

First move discs 1 and 2 to B, using C to help. Then disc 3, then discs 1 and 2 back onto it.

a worked answer

1 A to C, 2 A to B, 1 C to B, 3 A to C, 1 B to A, 2 B to C, 1 A to C. Disc 1 moves 4 times, disc 2 twice and disc 3 once. That is 7, one less than 8, which is 2 to the power 3.

this tests how it works, on the learn page

what a full answer includes
  • The 7 moves in that order.
  • Disc 1 four times, disc 2 twice and disc 3 once.
  • 7, which is 8 less 1.

question 6about 6 minutes

Suppose a tower of 64 discs is moved one disc a second. A friend says a computer making a billion moves a second would finish in a day.

  1. How many moves do 64 discs take?
  2. About how many years is that at one move a second?
  3. How long does the computer take, and where does your friend go wrong?
a hint

Use 2n−12^n - 1, the learn page's count. A year of 365 days is 31,536,000 seconds.

a worked answer

64 discs take 2 to the power 64, less 1, moves, which is 18,446,744,073,709,551,615. Divided by 31,536,000 seconds a year, that is about 585 billion years. A billion times faster is about 585 years, not a day. A billion times faster makes up for only 30 discs, as 2 to the power 30 is about a billion.

Question 1: how many moves, MM, does the method make for nn discs, from 1 up?
  1. the move: the rule

    the line:
    moves for n discs:those for n−1, then 1,then those for n−1\begin{gathered} \text{moves for } n \text{ discs:} \\ \text{those for } n - 1, \text{ then 1,} \\ \text{then those for } n - 1 \end{gathered}

    why it is allowed: To move nn discs, the method moves the n−1n - 1 above the biggest out of the way, moves the biggest once, and moves the n−1n - 1 back on top. For 3 discs, 3 moves, then 1, then 3, which is 7.

  2. the move: each disc in turn

    the line:
    disc n moves once, andeach smaller disc twice asoften as the next bigger\begin{gathered} \text{disc } n \text{ moves once, and} \\ \text{each smaller disc twice as} \\ \text{often as the next bigger} \end{gathered}
    3 discsfirst halfmiddlesecond half
    moves1 to 345 to 7
    which disc1, 2, 131, 2, 1
    From the run. Disc 3 moves once, in the middle. Each half moves discs 1 and 2 as a tower, so disc 2 moves twice and disc 1 four times.

    why it is allowed: By line 1, disc nn moves once, in the middle, and the tower above it moves twice. In each of those, disc n−1n - 1 is the biggest and moves once, so twice in all. Each splits the same way, so the third biggest disc moves 4 times, and on.

  3. the move: add them up

    the line:
    M=1+2+4+⋯+2n−1M = 1 + 2 + 4 + \dots + 2^{n - 1}

    why it is allowed: By line 2, disc nn moves once, disc n−1n - 1 twice, and on, doubling each time, down to disc 1. Disc 1 is n−1n - 1 doublings from disc nn, so it moves 2n−12^{n - 1} times. For 3, 1 + 2 + 4.

  4. the move: add the doublings

    the line:
    M=2n−1M = 2^n - 1
    where does this come from?
    question 1 of the page doubling and halving sumsAdd 1+2+4+⋯+2n1 + 2 + 4 + \dots + 2^n. What is the total?
    1. the move: name the sum

      the line:
      S=1+2+4+⋯+2nS = 1 + 2 + 4 + \dots + 2^n

      why it is allowed: Let SS be the doubling sum up to 2n2^n. For nn as 3, it is 1 + 2 + 4 + 8.

    2. the move: double both sides

      the line:
      2S=2+4+8+⋯+2n+12S = 2 + 4 + 8 + \dots + 2^{n + 1}

      why it is allowed: Each term doubled is the next one along, and 2n2^n becomes 2n+12^{n + 1}. Doubling both sides keeps them equal. The plan: the two sums share all but their ends.

    3. the move: take line 1 away

      the line:
      2S−S=(2+4+⋯+2n+1)−(1+2+⋯+2n)\begin{aligned} 2S - S = {} & (2 + 4 + \dots + 2^{n + 1}) \\ & - (1 + 2 + \dots + 2^n) \end{aligned}

      why it is allowed: Take SS from both sides of line 2. On the right, write SS out as line 1 does.

    4. the move: tidy the left side

      the line:
      S=(2+4+⋯+2n+1)−(1+2+⋯+2n)\begin{aligned} S = {} & (2 + 4 + \dots + 2^{n + 1}) \\ & - (1 + 2 + \dots + 2^n) \end{aligned}

      why it is allowed: Two lots of SS less one lot is one lot.

    5. the move: cancel what both brackets share

      the line:
      S=2n+1−1S = 2^{n + 1} - 1
      when n is 3124816
      first bracket24816
      second bracket1248
      left overtake away 116
      Line 4 when nn is 3. The 2, 4 and 8 cancel, leaving 16 less 1, which is 15.

      why it is allowed: Every term from 2 to 2n2^n is in both brackets and cancels, leaving 2n+12^{n + 1} less 1.

    6. the move: the terms before the last

      the line:
      1+2+⋯+2n−1=2(n−1)+1−1\begin{gathered} 1 + 2 + \dots + 2^{n - 1} \\ = 2^{(n - 1) + 1} - 1 \end{gathered}

      why it is allowed: The sum of line 5 stopping one term sooner: line 5 with n−1n - 1 for nn. For 3, it is 1 + 2 + 4. At nn as 0 no terms are left, adding to 0, and 2 to the power 0, less 1, is 0 too.

    7. the move: tidy the power

      the line:
      2(n−1)+1−1=2n−12^{(n - 1) + 1} - 1 = 2^n - 1

      why it is allowed: One more than n−1n - 1 is nn. For 3, 1 + 2 + 4 is 7, one less than 8.

    8. the move: read it

      the line:
      one less thanthe next term,under twice the last\begin{gathered} \text{one less than} \\ \text{the next term,} \\ \text{under twice the last} \end{gathered}

      why it is allowed: By lines 6 and 7, the terms before the last add to one less than it: the last outweighs them all. By line 5 the sum is under 2n+12^{n + 1}, twice the last.

    the whole page: doubling and halving sums

    why it is allowed: The box under this line shows a doubling sum from 1 is one less than its next term. Its lines 6 and 7 take this sum, ending at 2n−12^{n - 1}, to 2n−12^n - 1. For 3, 1 + 2 + 4 is 7, one less than 8.

  5. the move: a ceiling

    the line:
    M≤2nM \le 2^n

    why it is allowed: By line 4, MM is 2n−12^n - 1, 1 less than 2n2^n. For 3, 7 is at most 8.

  6. the move: read the bound

    the line:
    M∈O(2n)M \in O(2^n)

    why it is allowed: By line 5, with the fixed multiple 1. O(2n)O(2^n) means at most a fixed multiple of 2n2^n, from some nn on.

  7. the move: split the power

    the line:
    M=2n−1+(2n−1−1)M = 2^{n - 1} + (2^{n - 1} - 1)

    why it is allowed: By line 4, MM is 2n−12^n - 1, and 2n2^n is 2n−12^{n - 1} twice over, so take the 1 from the second. For 3, 7 is 4 plus 3.

  8. the move: a floor

    the line:
    M≥2n−1M \ge 2^{n - 1}
    nn2n−12^{n - 1}MM2n2^n
    1112
    2234
    3478
    105121,0231,024
    MM sits between half of 2n2^n and 2n2^n. Row 10 is section 7's count.

    why it is allowed: The bracket in line 7 is at least 0, as 2n−12^{n - 1} is at least 1. For 3, 7 is at least 4.

  9. the move: read the bound

    the line:
    M∈Ω(2n)M \in \Omega(2^n)

    why it is allowed: By line 8. 2n−12^{n - 1} is half of 2n2^n, so the fixed multiple is a half. Ω\Omega means at least a fixed multiple, above 0, from some nn on.

  10. the move: both together

    the line:
    M∈Θ(2n)M \in \Theta(2^n)

    why it is allowed: Lines 6 and 9 bound MM by the same growth, 2n2^n, from above and below. By line 1, one more disc doubles the moves and adds 1.

try it with a small nn: at n=3n = 3, line 3 gives M=7M = 7, which you can work out by hand

this tests where the formula comes from, on the learn page

what a full answer includes
  • 18,446,744,073,709,551,615 moves.
  • About 585 billion years.
  • About 585 years: a billion times faster makes up for only 30 discs, as 2 to the power 30 is about a billion.