CTK Exchange
Front Page
Movie shortcuts
Personal info
Awards
Reciprocal links
Terms of use
Privacy Policy

Interactive Activities

Cut The Knot!
MSET99 Talk
Games & Puzzles
Arithmetic/Algebra
Geometry
Probability
Eye Opener
Analog Gadgets
Inventor's Paradox
Did you know?...
Proofs
Math as Language
Things Impossible
My Logo
Math Poll
Other Math sit's
Guest book
News sit's

Recommend this site

Manifesto: what CTK is about Search CTK Buying a book is a commitment to learning Table of content Things you can find on CTK Chronology of updates Email to Cut The Knot Recommend this page

CTK Exchange

Subject: "Bicolor hanoi."     Previous Topic | Next Topic
Printer-friendly copy     Email this topic to a friend    
Conferences The CTK Exchange This and that Topic #477
Reading Topic #477
sfwc
Member since Jun-19-03
Feb-13-04, 12:53 PM (EST)
Click to EMail sfwc Click to send private message to sfwc Click to view user profileClick to add this user to your buddy list  
"Bicolor hanoi."
 
   As I was browsing ctk, I happened upon the page www.cut-the-knot.org/recurrence/BiColorHanoi.shtml. I don't know how general the 'more general formulations' you were thinking of were, but I tried the obvious one: putting lots of disks into the towers. So here is my solution to n-disk bicolor tower of hanoi:

Notation first: Since many formulas will be of this form, let (a, b, c) denote the expression (a * 4^n + b)/3 + c*n. I shall refer to moves by the pin the disk is taken from followed by the pin it goes to. So the solution to normal tower of hanoi with 3 disks in this notation is 02.01.21.02.10.12.02.

To move a disk of a particular size, it is necessary for all disks of lower size to be stacked up in a pile. Let the number of moves necessary to move such a pile with 2n disks in it from one pin to another be T_n. From the solution to the standard hanoi problem, we have T_n = 2^(n+1) - 2. That is:

T_2n = (6, -6, 0)
T_(2n - 1) = (3, -6, 0)

It is also worthwhile to see how long it takes to form such a tower. Such a tower may (when first formed) be on pin 2: let the minimal number of moves to reach this situation be B_n. Let the minimal number of moves to reach the other such situation (the tower on top of a stack on pin 1 or 2) be A_n. By induction on n, you may obtain:

A_2n = (8, -8, -3)
A_(2n-1) = (4, -4, -3)
B_2n = (10, -10, -3)
B_(2n-1) = (5, -5, -3)

Finally, cosider the final two layers together with the tower above them. It is necessary to swap the bases, get the next two the right way around, and do this moving the tower as little as possible. The best solution (8 tower moves, 11 other moves) also saves a little time by finishing with the tower in position A, since A_k is in general less than B_k. The sequence, starting with the tower on place 0 and considering the tower as a single object, is:

12.02.01.20.21.01.02.10.12.12.02.10.21.20.20.10.21.02.01

Handily, now that the bottom two layers are right there is no more need to worry: The other layers may be arranged as we wish. So the least number of moves for towers with n disks is L_n, satisfying L_n = A_(n-2) + B_(n-2) + 8*T_(n-2) + 11. That is:

L_(2n+2) = (66, -33, -6) = 11*(2^(2n+1) - 1) - 3*2n
L_(2n+1) = (33, -24, -6) = 11*(2^(2n) - 1) - 3*(2n-1)

These two are the same: L_k = 11*(2^(k-1) - 1) - 3(k-2) for k sufficiently large. Of course, for n <= 2 the values are different: L_0 = 0, L_1 = 3, L_2 = 10. However, it'suggests there is a nicer way to get the formula, but I don't know it. It gives an answer of 11*3 - 3 = 30 for k = 3 (the string is 10.12.02.02.01.20.20.21.01.01.02.10.10.12.12.02.02.10.21.21.20.20.10.10.21.02.02.01.20.21). Is that right? Anyway, if you generalised the problem any more it would be hard to get exact values, just upper and lower bounds. What sort of generalisation were you after?

Thankyou

sfwc
<><


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexb
Charter Member
1772 posts
Feb-13-04, 07:55 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
1. "RE: Bicolor hanoi."
In response to message #0
 
   >I don't
>know how general the 'more general formulations' you were
>thinking of were, but I tried the obvious one: putting lots
>of disks into the towers.

That's good enough. I think this is clear from the context too.

>So here is my solution to n-disk
>bicolor tower of hanoi:

With your permission, I'll move this to the main site. More people will see this.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
sfwc
Member since Jun-19-03
Feb-14-04, 05:21 PM (EST)
Click to EMail sfwc Click to send private message to sfwc Click to view user profileClick to add this user to your buddy list  
2. "RE: Bicolor hanoi."
In response to message #1
 
   OK. You have my permission. I hope I got the algebra right!

Thankyou

sfwc
<><


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexb
Charter Member
1772 posts
Feb-14-04, 05:35 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
3. "RE: Bicolor hanoi."
In response to message #2
 
   >OK. You have my permission.

Thank you. It's up there.

>I hope I got the algebra right!

Far as I can judge.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
fadil
guest
Feb-17-06, 06:07 PM (EST)
 
4. "RE: Bicolor hanoi."
In response to message #3
 
   i wish someone can help me please

i have problem with algorithm for Tower of Hanoi

the algorithm that i need should work with a starting position of discs on peg1 and finishing position with pegs on peg3 and with discs randomly placed on any of the three pegs.(n<=10)

i wish some one can help !!


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top

Conferences | Forums | Topics | Previous Topic | Next Topic

You may be curious to have a look at the old CTK Exchange archive.
Please do not post there.

|Front page| |Contents|

Copyright © 1996-2018 Alexander Bogomolny

Search:
Keywords:

Google
Web CTK