The Museum of HP Calculators


Flip for the HP 32SII

This program is Copyright (c) 2004 by Dr Paul Dale and is used here by permission.

This program is supplied without representation or warranty of any kind. Dr Paul Dale and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

This is a game based on a three by three grid. Each cell in the grid can hold either a 1 or a 0. The object of the game is to finish with a single 1 digit in the middle of the board. To do this you have to flip squares containing 1s over. Of course flipping a square also flips some of the adjacent squares which makes this a little more challenging. If during the course of play, you end up with a board full of 0s, you lose since you cannot continue.

The position is displayed on the calculator screen thus: i?1.23456789 which corresponds to the following board layout (which also happens to match the digit layout on the keyboard). To move select the number corresponding to the 1 digit you desire to flip and press R/S.
789
456
123

The adjacent squares flipped by each move are defined as follows.

A flip of a corner square also flips all adjacent squares.
Xx.
xx.
...

A flip of the middle square of an edge also flips all orthogonally adjacent squares.
xXx
.x.
...

A flip of the centre square also flips all orthogonally adjacent squares.
.x.
xXx
.x.

Any position can be solved in a maximum of nine moves and often less. Finding the required moves isn't at all easy. When you finish the calculator displays the number of moves it took you to win or lose.

To play the game, type XEQ W and you will begin play from a random starting position.

There is an alternative, however, if you type a number and then XEQ Z the initial board is setup such that the solution requires at most the number you specified number of moves to complete. Starting two or three moves from solution is good practice. Four becomes a bit more of a challenge. This option can potentially endless loop if an all 1 board appears during position generation. This, fortunately, cannot occur unless you specify a numbers of moves larger than four.

Program Listing

A01 LBL AF05 XEQ KK10 x<>yZ03 SF 10
A02 1F06 6K11 -Z04 FIX 8
A03 XEQ KF07 XEQ KK12 10^xZ05 4
A04 2F08 9K13 *Z06 10^x
A05 XEQ KF09 GTO KK14 STO+ AZ07 STO A
A06 4G01 LBL GK15 RTNN01 LBL N
A07 XEQ KG02 4O01 LBL ON02 RANDOM
A08 5G03 XEQ KO02 BAD MOVEN03 9
A09 GTO KG04 5O03 PSEN04 *
B01 LBL BG05 XEQ KL01 LBL LN05 1
B02 1G06 7L02 RCL AN06 +
B03 XEQ KG07 XEQ KL03 8N07 IP
B04 2G08 8L04 10^xN08 ENTER
B05 XEQ KG09 GTO KL05 /N09 XEQ J
B06 3H01 LBL HL06 STO iN10 x<>0?
B07 XEQ KH02 5L07 INPUT iN11 GTO N
B08 5H03 XEQ KL08 RCL iN12 x<>y
B09 GTO KH04 7L09 IPN13 STO i
C01 LBL CH05 XEQ KL10 x<=0?N14 XEQ(i)
C02 2H06 8L11 GTO ON15 DSE B
C03 XEQ KH07 XEQ KL12 9N16 GTO N
C04 3H08 9L13 x<y?N17 0
C05 XEQ KH09 GTO KL14 GTO ON18 STO B
C06 5I01 LBL IL15 x<>yN19 GTO L
C07 XEQ KI02 5L16 STO iW01 LBL W
C08 6I03 XEQ KL17 XEQ JW02 SF 10
C09 GTO KI04 6L18 x=0?W03 FIX 8
D01 LBL DI05 XEQ KL19 GTO OW04 9
D02 1I06 8L20 1W05 STO i
D03 XEQ KI07 XEQ KL21 STO+ BW06 0
D04 4I08 9L22 XEQ(i)W07 STO B
D05 XEQ KI09 GTO KL23 RCL AP01 LBL P
D06 5J01 LBL JL24 x<>0?P02 10
D07 XEQ KJ02 10L25 GTO MP03 *
D08 7J03 -L26 RCL BP04 RANDOM
D09 GTO KJ04 10^xL27 ALLP05 0.5
E01 LBL EJ05 RCL* AL28 LOSE inP06 +
E02 2J06 FPL29 PSEP07 IP
E03 XEQ KJ07 10L30 RTNP08 +
E04 4J08 *M01 LBL MP09 DSE i
E05 XEQ KJ09 IPM02 4P10 GTO P
E06 5J10 RTNM03 10^xP11 STO A
E07 XEQ KK01 LBL KM04 x<>y?P12 x=0?
E08 6K02 ENTERM05 GTO LP13 GTO W
E09 XEQ KK03 XEQ JM06 RCL BP14 4
E10 8K04 -2M07 ALLP15 10^x
E11 GTO KK05 *M08 Win inP16 x=y?
F01 LBL FK06 1M09 PSEP17 GTO W
F02 3K07 +M10 RTNP18 GTO L
F03 XEQ KK08 x<>yZ01 LBL Z
F04 5K09 9Z02 STO B

ProgramChecksumSize
A62F5013.5
B7532013.5
C762D013.5
D1907013.5
E131C016.5
F5180013.5
GD125013.5
H90AF013.5
IC35F013.5
J1B9E015.0
KBA4F030.5
O984F016.5
L7353055.5
M3E75024.0
Z08CD010.5
NA563028.5
WA462010.5
P8AFF035.0