Solving the Tower of Hanoi

Logic Level 3

Little Tommy is trying to solve the Tower of Hanoi with 5 disks.

The objective of the puzzle is to move the entire stack from one rod to another, following simple rules :

• Only one disk can be moved at a time.

• Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.

• No disk can be placed on top of a smaller disk.

His mom asks him to finish the game quickly and get back to his homework.

What is the minimum number of moves required to solve the puzzle ?


The answer is 31.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Akshat Sharda
Jan 16, 2016

Let us assume that T n T_n be the minimum number of moves to transfer n n disks from one rod to another.

So obviously, T 1 = 1 T_1=1 .

In our procedure we first transfer n 1 n-1 disks from one rod to another (requiring T n 1 T_{n-1} moves), then we move the largest disk to another rod (requiring 1 1 move) and then we finally transfer n 1 n-1 disks back on the largest disk (requiring another T n 1 T_{n-1} moves).

T n = 2 T n 1 + 1 , n > 0 T 2 = 3 T 3 = 7 T 4 = 15 T 5 = 31 \begin{aligned} \therefore T_n &=2T_{n-1}+1 \quad, \quad n>0 \\ T_2 &= 3 \\ T_3 &= 7 \\ T_4 &= 15 \\ T_5 &= \boxed{31} \end{aligned}


Generalization

It certainly looks as if T n = 2 n 1 , n 0 T_n=2^n-1 \quad, \quad n≥0 .

The induction follows for n > 0 n>0 , T n = 2 T n 1 + 1 = 2 ( 2 n 1 1 ) + 1 = 2 n 1 T n = 2 n 1 \begin{aligned} T_n &= 2T_{n-1}+1 \\ &= 2(2^{n-1}-1)+1 \\ &=2^n-1 \\ \therefore T_n &=2^n-1 \end{aligned}

Really nice solution. Great job with the generalization too!!

Racchit Jain - 5 years, 5 months ago

This is a classic :) !

Venkata Karthik Bandaru - 5 years, 5 months ago

Very interesting. I like it!

Felix Lu - 5 years, 4 months ago

T 4 = 15 T_4 = 15 is correct. But sometime a short sequence may not continue to be true when terms are not sufficient to resemble the whole thing. Could you elaborate how you could actually arrange for T 5 T_5 without mathematical induction?

Lu Chee Ket - 5 years, 4 months ago

I got 33 steps required. Since 33 was marked incorrect, I entered 31. My approach was a visual way using Excel. I don't know how the answer can be 31.

Lu Chee Ket - 5 years, 4 months ago

Log in to reply

It is 31. The trick to solving these in minimum moves is, If you got a pile to shift with odd number of discs then put the top disc where you want the bottom disc to be in the end. If the original pile is even, do the opposite.

A Former Brilliant Member - 5 years, 4 months ago

Log in to reply

Did you get the answer by actual trial for 5 discs? I found my answers to agree up to 4 discs as introduced by mathematical induction.

Lu Chee Ket - 5 years, 4 months ago

Log in to reply

@Lu Chee Ket Ah, no. I got the formula 2 n 1 2^{n} -1 by induction. But, I also tried this game for fun, and verified it up to 9 discs.

A Former Brilliant Member - 5 years, 4 months ago

Log in to reply

@A Former Brilliant Member Really? Then I must have made unnecessary steps. But I have tried to check for many times, yet unable to see the excess steps which I have made.

Lu Chee Ket - 5 years, 4 months ago

Log in to reply

@Lu Chee Ket Try what I said. If you have to shift an odd pile of discs to another pole, Put the top disc where you want the bottom discof pile to end.

If you have to shift an even pile of discs to another pole, put the top disc to the opposite of where you want the bottom disc of the pile to go.

A Former Brilliant Member - 5 years, 4 months ago

Log in to reply

@A Former Brilliant Member If I interpreted what you meant correctly, then this is just about which pole to end up with. My question is not which pole to end up with but I can't see which steps are excess from 33 steps I needed.

Lu Chee Ket - 5 years, 4 months ago

Log in to reply

@Lu Chee Ket I can't say what steps you have in excess, but the above method minimises the moves and doesn't have any excess. Maybe you can try twi games separately, one in which you retrace your steps , and other in which you do this, and compare.

A Former Brilliant Member - 5 years, 4 months ago

Log in to reply

@A Former Brilliant Member Did you really try to complete a task for 5 discs despite verifying for how to end up with which pole only, for 9 discs that you have claimed?

Lu Chee Ket - 5 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...