GLBasic forum
Main forum => Beta Tests => Topic started by: Hemlos on 2012Oct16

Beta test for Towers of Hanoi, brainteaser puzzle.
This program will solve the game for you with a recursive algorithm, displaying all the moves step by step.
There are many videos on youtube showing the brainteaser.
Im not taking credit for the original algorithm, it is converted from a python snipet, i found during the recursive lecture on MiTx 6.00x at Edx.org.
With a bit of tweaking, i was able to put it into glbasic in about 10 minutes.
I dont actually have the puzzle, so i dont know if this is properly working, but it looks like the same output from python.
If you have the puzzle....try it with an even number of stacks, then an odd number...
Test:
Try with 4 stacks, then 5 stacks.
Enjoy, have fun!
 regards Neil
[attachment deleted by admin]

Tried with 20 stacks from the outset. Had to remove the key press wait command in the print function because there were so many moves. After that I removed the showscreen command in the print function because even refreshing the screen every so many moves was taking too long. It runs out there are 1,038,575 moves needed to solve the puzzle with 20 stacks. Imagine attempting that in a lifetime but messing up a move 2/3 into the solution. :S

:o

LOL, if you mess up the first move, i think you end up on the wrong tower.
Its interesting, because the number of moves can be predicted with a formula, BASE 2 to the power of stacks(n) plus one.
(2^{n})+1 = minimum number of moves to solve.
:bed:

Huh. Maybe I made a typo then. Does happen.

I know, i wasnt laughing at that..
Your joke was funny, the million move puzzle.
Goodluck with THAT! haha