Post Reply 
(HP-67/97) a little fun with the fifteen puzzle
05-03-2017, 12:03 AM
Post: #15
RE: (HP-67/97) a little fun with the fifteen puzzle
(05-02-2017 03:03 PM)Dave Britten Wrote:  Here's a quick 16C version of Don's 65 program. The bit manipulation/counting instructions make this algorithm pretty trivial on this model: you don't have to implement any kind of loop for bit counting, just mask them off and use #B to get a count. Of course, the lack of register arithmetic adds a few unnecessary steps. But 25 steps and 2 registers ain't bad!

For this version, enter the row with the blank, GSB A, then enter each tile number followed by R/S. Make sure your word size is set to at least 16.

Code:
43,22,A         LBL A
42 34           CLEAR REG
44 2            STO 2
31              R/S
43,22,B         LBL B
1               1
34              X><Y
42 E            RLn
43 36           LSTx
34              X><Y
45 1            RCL 1
42 40           OR
44 1            STO 1
34              X><Y
1               1
40              +
42 8            MASKR
42 30           NOT
42 20           AND
43 7            #B
45 2            RCL 2
40              +
44 2            STO 2
31              R/S
22 B            GTO B

Thanks Dave, the 16c is a great calculator. In fact it was the first HP I ever owned, back in the early 80's.

Yes, I was thinking as I was looking at the 65 code that a loop would be unnecessary if we could only sum the bit range rather than looping through all the bits looking for a 1, but I didn't see an easy way to do that.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (HP-67/97) a little fun with the fifteen puzzle - Don Shepherd - 05-03-2017 12:03 AM



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