HP-41 Digit Swap Game

Back to main page Email me at: Gene!


This game is based on an old calculator game concept. The actual listing came from the HP club publication DATAFILE, V8N5P15, July/August 1988, in a column written by Mark Power.

The object of the game is to rearrange 8 numbers to form the number 12345678. To do this, you make moves by specifying a number in the range of 1 to 7. This number is the 'gap' between two of the digits around which the two halves of the number are rotated. Note that if you specify a 1 for your move, the left-most digit stays where it is and just the ones on the right rotate. Likewise, if you specify a 7, the right-most digit stays put and the ones on the left rotate. Here's an example:

Example Game:

XEQ 'SWAP'
SEED?        0.123456789 R/S
25178463     3 R/S
12584637     5 R/S
41258376     6 R/S
34125867     5 R/S
53412678     7 R/S
75341268     6 R/S
27534186     ...... and so on...
As you can see, I do not have it quite figured out yet. Eventually, you should make a move that results in a display that shows '24 MOVES' or such. I am told, that once you figure it out, you should be able to do this in 6-7 moves. Enjoy!
Program Listing:
Line      Instruction
01         LBL 'SWAP'
02         'SEED?'
03         PROMPT
04         STO 06
05         12345678
06         STO 02
07         STO 03
08         FIX 0
09         CF 29
10         5
11         STO 05
12         SF 25
13         LBL 01
14         RCL 06
15         997
16         *
17         FRC
18         STO 06
19         7
20         *
21         1
22         +
23         INT
24         XEQ 03
25         DSE 05
26         GTO 01
27         LBL 02
28         1
29         ST+ 05
30         RCL 02
31         RCL 03
32         X = Y?
33         GTO 04
34         STOP
35         X <= 0?
36         GTO 02
37         8
38         X <= Y?
39         GTO 02
40         X <> Y
41         XEQ 03
42         GTO 02
43         LBL 03
44         8
45         X <> Y
46         -
47         STO 00
48         RCL 03
49         RCL 00
50         10^X
51         /
52         INT
53         STO 01
54         LASTX
55         FRC
56         10
57         *
58         FRC
59         LASTX
60         INT
61         RCL 00
62         10^X
63         /
64         +
65         STO 04
66         RCL 01
67         10
68         /
69         INT
70         LASTX
71         FRC
72         8
73         RCL 00
74         -
75         10^X
76         *
77         +
78         RCL 04
79         +
80         RCL 00
81         10^X
82         *
83         STO 03
84         RTN
85         LBL 04
86         RCL 05
87         1
88         -
89         CLA
90         ARCL X
91         '-> MOVES'
92         AVIEW
93         FIX 4
94         SF 29
95         CLX
96         END

Visitors since 6/24/97