Overview
-The purpose of this game is to change the display from "----------" ( ten "-" characters ) into "**********" ( ten "*" characters )
-Pressing a numeric key ( from "1" to "9" ) followed by R/S change some
"-" into "*" and some "*" into "-"
-The transformation is reversible.
-Actually, each operation is a logical eXclusive OR ( "-" beeing 0 and
"*" beeing 1 ). The result is placed in the alpha register and displayed.
-If you find a solution, the HP-41 displays "**********" , you hear
a BEEP and your score is in registers X and R12.
-There is always ( at least ) one 4 keystroke solution which is stored
in register R11.
-Finding a solution without pen and paper is quite a feat!
-The first "XOR" program uses 103 data registers.
-In case you don't have enough room to execute SIZE 103 , "XOR2" is
then listed ( it is a little bit slower but only 16 registers are used
)
-Finally, "XOR3" is an easier version which displays 6 character strings
, using only 5 numeric keys ( from "1" to "5" ) , with a solution in 3
keystrokes.
Program#1
Data Registers: • R00 = random numbers ( Register R00 is to be initialized before executing "XOR" )
R01 to R10 correspond to the 10 displayed characters
R13 thru R22 correspond to the "1" key
R11 = one solution
-----------------------------------------
R12 = the score = the number of guesses
R93 thru R102 correspond to the "9" key
Flag: F10
Subroutine: /
-If you don't have an HP-41CX, replace lines 71-72 by
CLX STO 02 STO 03 STO 04 STO 05
STO 06 STO 07 STO 08 STO 09 STO 10
-The append character is denoted ~
01 LBL "XOR"
02 9 03 LBL 00 04 STO IND X 05 DSE X 06 GTO 00 07 STO 11 08 4 09 STO 12 10 9 11 LBL 01 12 STO Y 13 RCL 00 14 R-D 15 FRC 16 STO 00 17 * 18 10 19 ST* 11 20 SIGN 21 + 22 RCL IND X 23 ST+ 11 |
24 X<> IND Z
25 STO IND Y 26 RDN 27 SIGN 28 - 29 DSE 12 30 GTO 01 31 102.012 32 STO 02 33 LBL 02 34 RCL 00 35 R-D 36 FRC 37 STO 00 38 ST+ X 39 INT 40 STO IND 02 41 DSE 02 42 GTO 02 43 10 44 STO 01 45 ST* 06 46 ST* 07 |
47 ST* 08
48 ST* 09 49 12 50 ST+ 06 51 ST+ 07 52 ST+ 08 53 ST+ 09 54 LBL 03 55 SIGN 56 RCL IND 06 57 + 58 RCL IND 07 59 + 60 RCL IND 08 61 + 62 2 63 MOD 64 STO IND 09 65 DSE 06 66 DSE 07 67 DSE 08 68 DSE 09 69 DSE 01 |
70 GTO 03
71 2.01 72 CLRGX 73 LBL 04 74 SF 10 75 10 76 " " 77 LBL 05 78 RCL IND X 79 X=0? 80 CF 10 81 X=0? 82 "~-" 83 X#0? 84 "~*" 85 X<>Y 86 DSE X 87 GTO 05 88 AVIEW 89 FS?C 10 90 GTO 07 91 STOP 92 AVIEW |
93 10
94 * 95 12 96 + 97 10 98 LBL 06 99 RCL IND Y 100 RCL IND Y 101 + 102 2 103 MOD 104 STO IND Y 105 DSE Z 106 RDN 107 DSE X 108 GTO 06 109 SIGN 110 ST+ 12 111 GTO 04 112 LBL 07 113 RCL 12 114 BEEP 115 END |
( 193 bytes / SIZE 103 )
STACK | INPUTS | OUTPUTS |
X | / | Nb of guesses |
Example: With
0.1883185174 STO 00
XEQ "XOR" 49 seconds later ( t0 ) , the program stops and the HP-41 displays "----------"
Press ( for instance ) 1 R/S the previous
string is displayed again and 7 seconds later ( t1) , you'll
see "-*-*--***-"
2 R/S >>>> "**--*-****"
3 R/S >>>> "---**-*---"
4 R/S >>>> "----**--*-"
5 R/S >>>> "-*****--*-"
6 R/S >>>> "---*****--"
7 R/S >>>> "----*---*-" from
which we can gradually deduce the following informations:
-The 1st character is changed by 2 ; 3
-The 2nd ----------------------- 1 ; 3 ; 5 ; 6
-The 3rd ----------------------- 5 ; 6
-The 4th ----------------------- 1 ; 2 ; 3
; 4 ; 5 ; 7
-The 5th ----------------------- 2
-The 6th ----------------------- 4 ; 7
-The 7th ----------------------- 1 ; 4 ; 6
; 7
-The 8th ----------------------- 1 ; 3 ; 6
; 7
-The 9th ----------------------- 1 ; 3 ; 4
; 6 ; 7
-The 10th ---------------------- 2 ; 3
-We'll have a solution if all the 10 characters are changed an odd number of times, therefore we can try to "switch off" 4 ; 3 ; 1 ; 6:
4 R/S >>>> "---****---"
3 R/S >>>> "**--******"
1 R/S >>>> "*--***---*"
6 R/S >>>> "**********"
( BEEP ) and X = R12 = 11 = the number of our guesses. We have
found one solution = 2-5-7
-In this example, we didn't have to press 8 or 9 but the HP-41 gives
another solution in register R11 = 8-3-5-9.
Note:
-If you have an HP-41CX, lines 92-93 may be replaced with the 4 lines:
99 GETKEYX 48 -
and you'll only have to press the numeric key ( without R/S
).
Program#2
Data Registers: • R00 = random numbers ( Register R00 is to be initialized before executing "XOR2" )
R01 to R09 correspond to the 9 numeric keys
R10 corresponds to the 10 displayed characters R13 to
R15: temp.
R11 = one solution
R12 = the score
Flag: F10
Subroutine: /
01 LBL "XOR2"
02 9 03 LBL 00 04 STO IND X 05 DSE X 06 GTO 00 07 STO 11 08 4 09 STO 10 10 15 11 9 12 LBL 01 13 RCL 00 14 R-D 15 FRC 16 STO 00 17 RCL Y 18 * 19 10 20 ST* 11 21 SIGN 22 + 23 RCL IND X 24 ST+ 11 25 STO IND T 26 X<> IND Z 27 STO IND Y 28 RDN 29 SIGN |
30 ST- Z
31 - 32 DSE 10 33 GTO 01 34 9 35 STO 10 36 LBL 02 37 10 38 ENTER^ 39 CLX 40 LBL 03 41 10 42 * 43 RCL 00 44 R-D 45 FRC 46 STO 00 47 ST+ X 48 INT 49 + 50 DSE Y 51 GTO 03 52 STO IND 10 53 DSE 10 54 GTO 02 55 RCL IND 12 56 RCL IND 13 57 RCL IND 14 58 + |
59 +
60 10 61 STO 10 62 SIGN 63 STO 12 64 CLX 65 STO IND 15 66 X<>Y 67 LBL 04 68 ENTER^ 69 ENTER^ 70 SIGN 71 + 72 2 73 MOD 74 RCL 12 75 * 76 ST+ IND 15 77 CLX 78 10 79 ST* 12 80 / 81 INT 82 DSE 10 83 GTO 04 84 CLX 85 STO 12 86 LBL 05 87 SF 10 |
88 10
89 " " 90 RCL 10 91 LBL 06 92 ENTER^ 93 ENTER^ 94 2 95 MOD 96 X=0? 97 CF 10 98 X=0? 99 "~-" 100 X#0? 101 "~*" 102 CLX 103 10 104 / 105 INT 106 DSE Y 107 GTO 06 108 AVIEW 109 FS?C 10 110 GTO 08 111 STOP 112 AVIEW 113 10 114 STO 13 115 SIGN 116 STO 14 |
117 CLX
118 X<> 10 119 RCL IND Y 120 + 121 LBL 07 122 STO Y 123 2 124 MOD 125 RCL 14 126 * 127 ST+ 10 128 CLX 129 10 130 ST* 14 131 / 132 INT 133 DSE 13 134 GTO 07 135 SIGN 136 ST+ 12 137 GTO 05 138 LBL 08 139 RCL 12 140 BEEP 141 END |
( 208 bytes / SIZE 016 )
STACK | INPUTS | OUTPUTS |
X | / | Nb of guesses |
-This program is slower than "XOR": t0 = 62
seconds ; t1 = 11 seconds.
-The 10 characters are displayed in the reversed order but this doesn't
change the strategy.
Program#3
Data Registers: • R00 = random numbers ( Register R00 is to be initialized before executing "XOR3" )
R01 to R06 correspond to the 6 displayed characters
R09 thru R14 correspond to the "1" key
R07 = one solution
-----------------------------------------
R08 = the score
R33 thru R38 correspond to the "5" key
Flag: F10
Subroutine: /
01 LBL "XOR3"
02 5 03 LBL 00 04 STO IND X 05 DSE X 06 GTO 00 07 STO 07 08 3 09 STO 08 10 5 11 LBL 01 12 STO Y 13 RCL 00 14 R-D 15 FRC 16 STO 00 17 * 18 10 19 ST* 07 20 SIGN 21 + 22 RCL IND X 23 ST+ 07 |
24 X<> IND Z
25 STO IND Y 26 RDN 27 SIGN 28 - 29 DSE 08 30 GTO 01 31 38.008 32 STO 02 33 LBL 02 34 RCL 00 35 R-D 36 FRC 37 STO 00 38 ST+ X 39 INT 40 STO IND 02 41 DSE 02 42 GTO 02 43 6 44 STO 01 45 ST* 03 46 ST* 04 |
47 ST* 05
48 8 49 ST+ 03 50 ST+ 04 51 ST+ 05 52 LBL 03 53 SIGN 54 RCL IND 03 55 + 56 RCL IND 04 57 + 58 2 59 MOD 60 STO IND 05 61 DSE 03 62 DSE 04 63 DSE 05 64 DSE 01 65 GTO 03 66 CLX 67 STO 02 68 STO 03 69 STO 04 |
70 STO 05
71 STO 06 72 LBL 04 73 SF 10 74 6 75 " " 76 LBL 05 77 RCL IND X 78 X=0? 79 CF 10 80 X=0? 81 "~-" 82 X#0? 83 "~*" 84 X<>Y 85 DSE X 86 GTO 05 87 AVIEW 88 FS?C 10 89 GTO 07 90 STOP 91 AVIEW 92 6 |
93 *
94 8 95 + 96 6 97 LBL 06 98 RCL IND Y 99 RCL IND Y 100 + 101 2 102 MOD 103 STO IND Y 104 DSE Z 105 RDN 106 DSE X 107 GTO 06 108 SIGN 109 ST+ 08 110 GTO 04 111 LBL 07 112 RCL 08 113 BEEP 114 END |
( 178 bytes / SIZE 039 )
STACK | INPUTS | OUTPUTS |
X | / | Nb of guesses |
Example: With
1 STO 00
XEQ "XOR3" , 20 seconds later, the HP-41 displays "------"
1 R/S >>>> ( 5 seconds later
) "-*-**-"
2 R/S >>>> "---**-"
3 R/S >>>> "*-**--"
4 R/S >>>> "-*-*-*"
5 R/S >>>> "*--**-"
Similar arguments suggest to switch off 3 and 5
3 R/S >>>> "--**--"
5 R/S >>>> "******"
( BEEP ) and X = R08 = 7 guesses.
-We have found the solution 1-2-4 which is confirmed by
register R07 = 241.