Solving the Tower of Hanoi with 4 Pegs

  • Thread starter Thread starter msmith12
  • Start date Start date
  • Tags Tags
    Tower
AI Thread Summary
The Tower of Hanoi problem involves moving n disks from one peg to another using three pegs, with the minimum moves defined by T(n) = 2^n - 1. The challenge increases with four pegs, leading to the need for a new formula, W(n), which represents the minimum moves required. A proposed strategy involves moving n-2 disks to an empty peg, then sequentially moving the last two disks to the target peg, resulting in the recurrence relation a(n) = 3 + 2 * a(n - 2). Experimental findings suggest that for odd n, a(n) = 2^((n-1)/2 + 2) - 3, and for even n, a(n) = 3 * (2^(n/2) - 1). The discussion explores the complexities of optimizing disk movements and the potential for dividing disks between spare pegs.
msmith12
Messages
41
Reaction score
0
There is a famous problem called the tower of hanoi in which you have n disks of increasing diameter, and three pegs. The object is to move them from one peg to another in such a way that no larger disk is on top of a smaller disk.

the number of moves is defined by
<br /> T(n)=2^{n}-1<br />

A far more interesting and complicated problem, is, what is the minimum number of moves if you have 4 pegs instead of three?

Bonus: what is a formula in terms of
W(n) and T(n) --(where W(n) is the 4 peg number and T(n) is the number of 3 peg moves).
 
Physics news on Phys.org
Well, one strategy is to first move n-2 discs to one of the empty posts, then move the second-to-last disc to the other empty post, then move the last disc to the target post, then move the second-to-last disc to the target post, then move the n-2 discs to the target post. This gives a(n) = 3 + 2 * (a(n - 2)), with a(1) and a(2) being 1 and 3. Some experimentation (I don't know how to do it methodologically) shows that for odd n, a(n) = 2^((n-1)/2 + 2) - 3, and for even n, a(n) = 3 * (2^(n/2) - 1). Of course, I have no reason to believe this is the best strategy.
 
Now I think it is the best strategy. To move the bottom disk you have to move somehow all the disks above it. To move the second-to-last-disk it must go onto a post that is already empty. The next step is clear, moving the last disk to target, and the step after that is equally clear, moving second-to-last disk to target.

I was thinking that maybe there would be some way to divide up the disks between the two spare posts in a way that might save future moves, but I guess not.
 
Thread 'RIP Chen Ning Yang (1922-2025)'
https://en.wikipedia.org/wiki/Yang_Chen-Ning ( photo from http://insti.physics.sunysb.edu/~yang/ ) https://www.nytimes.com/2025/10/18/science/chen-ning-yang-dead.html https://www.bbc.com/news/articles/cdxrzzk02plo https://www.cpr.cuhk.edu.hk/en/press/mourning-professor-yang-chen-ning/ https://www.stonybrook.edu/commcms/physics/about/awards_and_prizes/_nobel_and_breakthrough_prizes/_profiles/yangc https://www.stonybrook.edu/commcms/physics/people/_profiles/yangc...
Thread 'In the early days of electricity, they didn't have wall plugs'
Hello scientists, engineers, etc. I have not had any questions for you recently, so have not participated here. I was scanning some material and ran across these 2 ads. I had posted them at another forum, and I thought you may be interested in them as well. History is fascinating stuff! Some houses may have had plugs, but many homes just screwed the appliance into the light socket overhead. Does anyone know when electric wall plugs were in widespread use? 1906 ad DDTJRAC Even big...
Back
Top