Weakest calculator/pocket computer that can do Tower of Hanoi?
08-14-2018, 12:47 AM (This post was last modified: 09-10-2018 04:09 PM by Thomas Klemm.)
Post: #25
 Thomas Klemm Senior Member Posts: 1,804 Joined: Dec 2013
RE: Weakest calculator/pocket computer that can do Tower of Hanoi?
(08-13-2018 11:47 AM)Thomas Klemm Wrote:  There are 12 lines left that could be used for a loop or a fancy display or what not.

Meanwhile I was able to remove another step.
This allows to output a single line in an infinite loop:
Code:
01 1           ; 1 02 STO 0       ; n=1 03▸RCL 0       ; k=n 04 1           ; 1 k 05 STO 1       ; a=1 k 06 STO 2       ; m=1 k 07▸R↓          ; k 08 2           ; 2 k 09 ÷           ; k/2 10 FRAC        ; {k/2} 11 x≠0         ; k % 2 ≠ 0 ? 12 GTO 20      ; done 13 LASTx       ; k'=k/2 14 2           ; 2 k' 15 STO × 1     ; a'=2a 16 R↓          ; k' 17 1           ; 1 k' 18 STO + 2     ; m'=m+1 19 GTO 07      ; while 20▸RCL 0       ; n 21 RCL 1       ; a n 22 +           ; n+a 23 3           ; modulo 3 24 ÷           ; 25 FRAC        ; 26 4           ; 27 ×           ; 28 INT         ; to=(n+a)%3 29 1           ; 30 0           ; 10 to 31 ÷           ; 0.to 32 RCL 0       ; n 0.to 33 RCL 1       ; a n 0.to 34 -           ; n-a 0.to 35 3           ; modulo 3 36 ÷           ; 37 FRAC        ; 38 4           ; 39 ×           ; 40 INT         ; from=(n-a)%3 0.to 41 +           ; from.to 42 1           ; 1 43 STO + 0     ; n=n+1 44 10^x        ; 10 from.to 45 ÷           ; 0.from-to 46 RCL 2       ; disk 0.from-to 47 +           ; disk.from-to 48 R/S         ; show move 49 GTO 03      ; next n

Make sure to have the display set to FIX 2 which is the default after starting up the calculator.

Example:

GTO 00
R/S
X: 1.02
R/S
X: 2.01
R/S
X: 1.21
R/S
X: 3.02
R/S
X: 1.10

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

Cheers
Thomas
 « Next Oldest | Next Newest »

 Messages In This Thread Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-11-2018, 05:26 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-11-2018, 06:42 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-11-2018, 06:52 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-11-2018, 08:35 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 01:46 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-12-2018, 01:52 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 07:16 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 07:46 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 08:10 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 09:35 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 01:19 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 01:16 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 01:32 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-12-2018, 05:08 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-12-2018, 06:07 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-13-2018, 01:38 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Okken - 08-13-2018, 03:40 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-13-2018, 07:03 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-13-2018, 12:45 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-13-2018, 11:47 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-13-2018, 01:31 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-13-2018, 01:07 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-13-2018, 03:58 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-13-2018, 04:02 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-14-2018 12:47 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Paul Dale - 08-14-2018, 04:18 AM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Jake Schwartz - 08-15-2018, 03:49 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-15-2018, 04:39 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Gene - 08-15-2018, 05:31 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Thomas Klemm - 08-15-2018, 08:12 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-29-2018, 11:32 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - Dave Britten - 08-30-2018, 03:36 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 08-30-2018, 11:57 PM RE: Weakest calculator/pocket computer that can do Tower of Hanoi? - SlideRule - 10-29-2018, 02:15 PM

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