# HP Forums

Full Version: (16C) Tower of Hanoi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I used from Binary solution of Tower of Hanoi:

Quote:Another formulation is from peg (m - (m & -m)) % 3 to peg (m + (m & -m)) % 3

This is an iterative solution for the HP-16C:
Code:
```   000 {          }     001 {    45 32 } RCL I    002 {       36 } ENTER    003 {       36 } ENTER    004 {       49 } CHS    005 {    42 20 } f AND    006 {       30 } -    007 {    45 32 } RCL I    008 {    43 36 } g LSTx    009 {       40 } +    010 {        3 } 3    011 {    42  9 } f RMD    012 {       34 } X<=>Y    013 {        3 } 3    014 {    42  9 } f RMD    015 {    43 24 } g ISZ```

Initialisation

DEC
1
STO I
RTN

Endless Loop

R/S
Y: to
X: from

Example:

R/S
0
R↓
2

R/S
0
R↓
1

R/S
2
R↓
1

R/S
0
R↓
2

Thus:
1. move disk from peg 0 to peg 2
2. move disk from peg 0 to peg 1
3. move disk from peg 2 to peg 1
4. move disk from peg 0 to peg 2

It doesn't tell you which disk to move but that's not needed.

This solution came up in this older thread: Weakest calculator/pocket computer that can do Tower of Hanoi?
It is an excerpt from post #20 and post #30.

I stumbled upon this thread recently: New HP 16C Simulator released: JRPN 16C
On the linked page JRPN - Jovial Reverse Polish Notation Calculators Valentin's solution is mentioned:
You can start the simulator with my program here: HP-16C
The state is already initialised so you can start with R/S
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :