Recursively solving the Tower of Hanoi puzzle

We already presented a ROBOLAB solution for JP Brown's great Tower of Hanoi robot. But we want to go a bit farther : implementing an Ultimate ROBOLAB recursive solution.

The Tower of Hanoi is often used to illustrate a divide and conquer strategy that consists in dividing a problem in smaller problems of the same nature. That's exactly what has to be done here. The principle is to have the computer (in our case the RCX) solve the challenge for (n-1) disks, when it has to solve it for n disks.

Here the Ultimate program. Note that you may choose the number of disks by pressing the RCX View button. The solving is executed, if you press the Prgm-button. The present program only shows the steps in the RCX display, but you also could have your robot move, grab and drop real disks.

The program uses an efficient RCX-button debouncer.

Also note that Ultimate Robolab allows function calls with more than one function-argument.

download .srec-file

download Ultimate ROBOLAB Tower of Hanoi code

 


RetourMain Page