Solve 4 Pegs Hanoi Tower: Algorithm & Best Move Ideas

  • Thread starter Stephanus
  • Start date
  • Tags
    tower
In summary, according to Steven, the standard way is to use a recursive algorithm, but for a random position, well... Maybe?
  • #1
Stephanus
1,316
104
Dear PF Forum,
Do anybody know the algorithm for 4 pegs Hanoi Tower?
In regular initial, we can use array.
But what if the initial configuration is random?
I can do it in 3 pegs, but I've been searching algorithm for 4 pegs every day, on my bed, before I go to sleep. But I can't find any.
The algorithm should find the best move. Not using "brute force"!

Thanks for any idea.

Steven
 
Technology news on Phys.org
  • #2
The standard way is to use a recursive algorithm:
  1. 3 disks can be done directly.
  2. Assume that you have found how to do it with n disks
    • Use this to move n disks to one of the spare pegs
    • Move the bottom disk to the goal peg
    • Move the n disks from the spare peg to the goal peg.
 
  • Like
Likes Stephanus
  • #3
Svein said:
The standard way is to use a recursive algorithm:
  1. 3 disks can be done directly.
  2. Assume that you have found how to do it with n disks
    • Use this to move n disks to one of the spare pegs
    • Move the bottom disk to the goal peg
    • Move the n disks from the spare peg to the goal peg.
Yes, of course Svein. But it's not the best/shortest move is it?
 
  • #4
According to Wikipedia, the optimal solution with 4 pegs is an unsolved problem. And randomizing the starting position certainly does not help.
 
Last edited:
  • Like
Likes Stephanus
  • #5
mfb said:
According to Wikipedia, the optimal solution with 4 pegs http://Tower_of_Hanoi#With_four_pegs_and_beyond . And randomizing the starting position certainly does not help.

Thanks mfb,
There is, actually, an algorithm for a sorted initial position, but for a random position, well... Maybe? I've been trying for two months before I sleep. Still can't find solutions. Perhaps you're right.
 
Last edited by a moderator:
  • #6
(I fixed the link in the previous post)

On the positive side, if you find an efficient algorithm, you can write a paper about it.
 
  • Like
Likes Stephanus

1. What is the purpose of the "Solve 4 Pegs Hanoi Tower" puzzle?

The purpose of the "Solve 4 Pegs Hanoi Tower" puzzle is to move a stack of discs from one peg to another, following the rules of the puzzle. This puzzle is often used as an exercise in problem-solving and algorithm development.

2. What are the rules of the "Solve 4 Pegs Hanoi Tower" puzzle?

The rules of the puzzle are as follows:

  • There are 4 pegs labeled A, B, C, and D.
  • There are a number of discs of different sizes on peg A, stacked in order from largest on the bottom to smallest on the top.
  • The goal is to move all the discs from peg A to peg D.
  • Only one disc can be moved at a time.
  • A disc can only be placed on top of a larger disc or an empty peg.

3. What is the algorithm for solving the "Solve 4 Pegs Hanoi Tower" puzzle?

The algorithm for solving the puzzle is as follows:

  1. Step 1: Move the top disc from peg A to peg B.
  2. Step 2: Move the remaining stack of discs (from smallest to largest) from peg A to peg C.
  3. Step 3: Move the top disc from peg B to peg D.
  4. Step 4: Move the remaining stack of discs (from smallest to largest) from peg C to peg D.
  5. Repeat this pattern until all the discs are on peg D.

4. Are there any variations of the "Solve 4 Pegs Hanoi Tower" puzzle?

Yes, there are many variations of the puzzle including different numbers of pegs and discs. Some variations also have added rules, such as limiting the number of moves or allowing only certain size discs to be moved at a time.

5. What is the best move to make in the "Solve 4 Pegs Hanoi Tower" puzzle?

The best move depends on the current state of the puzzle and the specific algorithm being used. However, in general, the best move is to move the smallest disc that is not currently blocked by a larger disc. This will create the most efficient path for solving the puzzle.

Similar threads

  • Programming and Computer Science
Replies
25
Views
5K
  • Programming and Computer Science
Replies
14
Views
2K
  • Mechanical Engineering
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
7K
Replies
5
Views
431
  • Programming and Computer Science
Replies
29
Views
3K
Replies
56
Views
708
Replies
16
Views
6K
  • Programming and Computer Science
Replies
4
Views
1K
Back
Top