The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

Re: a challenge related to the 15 puzzle
Message #1 Posted by Don Shepherd on 18 Jan 2011, 10:20 p.m.

Here is a BASIC version for the HP-71b, one of my favorite calculators. It is much faster than the 32sii version, probably because it doesn't have to decode multiple numbers stored in a register.

HP 71b program to determine 15 puzzle solvability

10 destroy all 20 integer a(16) 30 data 11,5,14,7,15,2,9,4,6,0,1,13,10,3,12,8 40 for i=1 to 16 50 read a(i) 60 if a(i)=0 then let b=ip((i+3)/4) 70 next i 80 for i=1 to 15 90 for j=i+1 to 16 100 if a(j)<>0 and a(j)<a(i) then let b=b+1 110 next j 120 next i 130 if mod(b,2)=0 then disp "solvable" else disp "unsolvable" 140 disp "inversions = ";b

      
Re: a challenge related to the 15 puzzle
Message #2 Posted by Allen on 18 Jan 2011, 11:01 p.m.,
in response to message #1 by Don Shepherd

Nice-- and easy on the eyes.. I started a 50g program that uses PUT,PUTI,GET, LOC and REPL. It's compact, but incomplete as yet.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall