A very photogenic couple
08-24-2018, 12:20 PM
Post: #3
 Dave Britten Senior Member Posts: 2,237 Joined: Dec 2013
RE: A very photogenic couple
Here's my Tower of Hanoi solver that I adapted from an fx-7000G version I wrote. Instead of a graphical display, it uses this output format:

FT.XYZ

Where F is the stack to move from, T is the stack to move to, and X, Y, and Z indicate the total number of disks on the left, middle, and right stacks respectively.

This uses extensive register packing to store all three stacks in just three variables, as well as a small array to store pointers to the tops of each stack. (Note that there are some uses of variable O; be careful not to mistake this for zero.)

Code:
==Prog 0== Fix 3 Mcl "DISCS":?→N 2Frac (N÷2→O 2^N-1→M 9→P~R N→U 9→V 18→W U→I Lbl 0 N-I+1→D Prg 2 Dsz I Goto 0 1→B Prg 3 Lbl 1 B→F B+1+O→G G>3⇒G-3→G B+2-O→B B>3⇒B-3→B T[F→I Prg 1 D→C T[G→I Prg 1 C<D⇒Goto 2 D→C F→S G→F S→G Lbl 2 0→D T[F→I Prg 2 Dsz T[F]:Deg (no-op) Isz T[G] C→D T[G→I Prg 2 Prg 3 Dsz M Goto 1 Norm ==Prog 1== P[Int (I÷9→Z 9Frac (I÷9→E 10Frac (.1Int (Z÷(10^)E→D ==Prog 2== D→H Prg 1 Z-D(10^)E+H(10^)E→P[Int(I÷9)] ==Prog 3== 10F+G+.1U+.01(V-9)+.001(W-18◢
 « Next Oldest | Next Newest »

 Messages In This Thread A very photogenic couple - Dave Britten - 08-22-2018, 01:57 PM RE: A very photogenic couple - Csaba Tizedes - 08-24-2018, 08:45 AM RE: A very photogenic couple - Dave Britten - 08-24-2018 12:20 PM RE: A very photogenic couple - BruceH - 08-25-2018, 04:41 PM RE: A very photogenic couple - Dave Britten - 08-25-2018, 06:43 PM RE: A very photogenic couple - rickh57 - 02-27-2021, 04:06 PM RE: A very photogenic couple - Hollerith - 02-28-2021, 04:03 PM

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