(34C) Hanoi Towers - Automatic & Manual resolutions
|
01-22-2020, 12:42 AM
(This post was last modified: 01-22-2020 12:46 AM by Archilog.)
Post: #1
|
|||
|
|||
(34C) Hanoi Towers - Automatic & Manual resolutions
Here is a program to solve the classical Hanoi Towers problem with your HP-34C.
How can I use it? There are two ways to proceed: - You let the HP compute each move (Press A - "A" for "Automatic"); - You try to be faster! (Press B - "B" for "Be faster!"). In automatic mode, the HP-34C will display every reception tower (for example 3.1 for the third tower with the smallest disk) until the last (3.987654321) move. This version will last more than two hours (2 h 8 m 32 s on my HP-34C S/N 2117S....), this counter-performance being partly due to display management (only disks are displayed from each register, not zeroes). If you decide to challenge your calculator, it will display at each turn the three towers, waiting for your answer: - Enter the first tower, - Press [ENTER], - Enter the second tower, - Press [R/S]. Like in real life, there is no control of the validity of your choice. If you want to check the towers state again before playing, press [FIX] [9] and then recall one of the third first registers ([RCL] [1], [2] or [3]): content will be display as 9.987654321 for example, where the integer represents the disks cardinal number in the register. Once that is done, proceed as usual. Example: The HP-34C displays successively: 1.987654321, 2., 3., then waits for your inputs, for instance: [1] [ENTER] [3] [R/S], The calculator displays: 1.98765432, 2., 3.1, Your next move: [1] [ENTER] [2] [R/S], etc. At the end of the game, register 0 contains the number of your moves. Congratulations! (I did that once upon a time... well, it was pretty hard, you can believe me...) Note: if you want to pause the game in B mode, just turn off the calculator when it is waiting for your move. After a while, turn it on again, press [GTO] [.] [0] [2] [2] and enter your move as usual. Program: (part I) Code:
(part II) Code:
This program was first published there some weeks ago. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)