Post Reply 
Weakest calculator/pocket computer that can do Tower of Hanoi?
08-13-2018, 01:38 AM
Post: #17
RE: Weakest calculator/pocket computer that can do Tower of Hanoi?
(08-12-2018 05:08 PM)Thomas Klemm Wrote:  PS: I wasn't aware that the ENTER in the first line is needed.

Specify that the program is run after ENTER has been pressed. To expand this to a complete solution the oddness of the input is required, so a STO as the first step avoids the issue.
I wonder if the sign of the output could indicate the direction of the move rather than calculating the final position?

Anyway, here is a 49 step programme for the HP 25 that gives the solution to an n level Tower of Hanoi problem:

Code:
01  STO 4
02  1
03  2
04  STO 0
05  1
06  3
07  STO 1
08  2
09  3
10  STO 2
11  RCL 4
12  2
13  /
14  FRAC
15  x=0?
16  GTO 22
17  RCL 0
18  RCL 1
19  STO 0
20  Rv
21  STO 1
22  2
23  RCL 4
24  y^x
25  .
26  9
27  -
28  INT
29  RCL 0
30  PSE
31  Rv
32  1
33  -
34  x=0?
35  GTO 00
36  RCL 1
37  PSE
38  Rv
39  1
40  -
41  x=0?
42  GTO 00
43  RCL 2
44  PSE
45  Rv
46  1
47  -
48  x!=0?
49  GTO 29

To run:
  1. GTO 00
  2. Enter n
  3. R/S


The program will display a sequence of two digits numbers that represent the poles moved between, pick the legal move in each case.

For a three high tower these are:

Code:
Display   Meaning
13        move the disc from pole 1 to 3
12        move the disc from pole 1 to 2
23        move the disc from pole 3 to 2
13        move the disc from pole 1 to 3
12        move the disc from pole 2 to 1
23        move the disc from pole 2 to 3
13        move the disc from pole 1 to 3


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-13-2018 01:38 AM



User(s) browsing this thread: 1 Guest(s)