Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>An iterative solution for the tower of Hanoi with Y=3 Towers and X discs and can be found on <a href="http://en.wikipedia.org/wiki/Towers_of_hanoi#Iterative_solution" rel="nofollow">Wikipedia</a>:</p> <p><strong>For an even number of disks:</strong></p> <ul> <li>make the legal move between pegs A and B</li> <li>make the legal move between pegs A and C</li> <li>make the legal move between pegs B and C repeat until complete</li> </ul> <p><strong>For an odd number of disks:</strong></p> <ul> <li>make the legal move between pegs A and C</li> <li>make the legal move between pegs A and B</li> <li>make the legal move between pegs B and C repeat until complete</li> </ul> <p>In each case, a total of 2^X-1 moves are made. <strong>The number of moves with this algorithm is only <a href="http://en.wikipedia.org/wiki/Tower_of_Hanoi#Logical_analysis_of_the_recursive_solution" rel="nofollow">minimal for Y=3</a>.</strong></p> <p>This solution ignores the other towers, so it works with any Y >= 3 and any X.</p> <blockquote> <p>Although the three-peg version has a simple recursive solution as outlined above, the optimal solution for the Tower of Hanoi problem with four pegs (called Reve's puzzle), let alone more pegs, is still an open problem. This is a good example of how a simple, solvable problem can be made dramatically more difficult by slightly loosening one of the problem constraints.</p> </blockquote> <p>Quoted from <a href="http://en.wikipedia.org/wiki/Tower_of_Hanoi#Four_pegs_and_beyond" rel="nofollow">Wikipedia</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload