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.

7 8 9
4 5 6
1 2 3

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

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

X x .
x x .
. . .

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

x X x
. x .
. . .

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

. x .
x X x
. 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 A F05 XEQ K K10 x⇔y Z03 SF 10
A02 1 F06 6 K11 - Z04 FIX 8
A03 XEQ K F07 XEQ K K12 10x Z05 4
A04 2 F08 9 K13 × Z06 10x
A05 XEQ K F09 GTO K K14 STO+ A Z07 STO A
A06 4 G01 LBL G K15 RTN N01 LBL N
A07 XEQ K G02 4 O01 LBL O N02 RANDOM
A08 5 G03 XEQ K O02 BAD MOVE N03 9
A09 GTO K G04 5 O03 PSE N04 ×
B01 LBL B G05 XEQ K L01 LBL L N05 1
B02 1 G06 7 L02 RCL A N06 +
B03 XEQ K G07 XEQ K L03 8 N07 IP
B04 2 G08 8 L04 10x N08 ENTER
B05 XEQ K G09 GTO K L05 ÷ N09 XEQ J
B06 3 H01 LBL H L06 STO i N10 x≠0?
B07 XEQ K H02 5 L07 INPUT i N11 GTO N
B08 5 H03 XEQ K L08 RCL i N12 x⇔y
B09 GTO K H04 7 L09 IP N13 STO i
C01 LBL C H05 XEQ K L10 x≤0? N14 XEQ(i)
C02 2 H06 8 L11 GTO O N15 DSE B
C03 XEQ K H07 XEQ K L12 9 N16 GTO N
C04 3 H08 9 L13 x<y? N17 0
C05 XEQ K H09 GTO K L14 GTO O N18 STO B
C06 5 I01 LBL I L15 x⇔y N19 GTO L
C07 XEQ K I02 5 L16 STO i W01 LBL W
C08 6 I03 XEQ K L17 XEQ J W02 SF 10
C09 GTO K I04 6 L18 x=0? W03 FIX 8
D01 LBL D I05 XEQ K L19 GTO O W04 9
D02 1 I06 8 L20 1 W05 STO i
D03 XEQ K I07 XEQ K L21 STO+ B W06 0
D04 4 I08 9 L22 XEQ(i) W07 STO B
D05 XEQ K I09 GTO K L23 RCL A P01 LBL P
D06 5 J01 LBL J L24 x≠0? P02 10
D07 XEQ K J02 10 L25 GTO M P03 ×
D08 7 J03 - L26 RCL B P04 RANDOM
D09 GTO K J04 10x L27 ALL P05 0.5
E01 LBL E J05 RCL× A L28 LOSE in P06 +
E02 2 J06 FP L29 PSE P07 IP
E03 XEQ K J07 10 L30 RTN P08 +
E04 4 J08 × M01 LBL M P09 DSE i
E05 XEQ K J09 IP M02 4 P10 GTO P
E06 5 J10 RTN M03 10x P11 STO A
E07 XEQ K K01 LBL K M04 x≠y? P12 x=0?
E08 6 K02 ENTER M05 GTO L P13 GTO W
E09 XEQ K K03 XEQ J M06 RCL B P14 4
E10 8 K04 -2 M07 ALL P15 10x
E11 GTO K K05 × M08 Win in P16 x=y?
F01 LBL F K06 1 M09 PSE P17 GTO W
F02 3 K07 + M10 RTN P18 GTO L
F03 XEQ K K08 x⇔y Z01 LBL Z
F04 5 K09 9 Z02 STO B

Program Checksum Size
A 62F5 013.5
B 7532 013.5
C 762D 013.5
D 1907 013.5
E 131C 016.5
F 5180 013.5
G D125 013.5
H 90AF 013.5
I C35F 013.5
J 1B9E 015.0
K BA4F 030.5
O 984F 016.5
L 7353 055.5
M 3E75 024.0
Z 08CD 010.5
N A563 028.5
W A462 010.5
P 8AFF 035.0

Go back to the software library
Go back to the main exhibit hall