Password game for both 32SII and 15C Message #1 Posted by GWB on 28 Jan 2005, 7:05 p.m.
Hi,
I've just bought in a shop just three or four blocks away from my place a second HP 32SII, a brown bezel one, Singapore made. It had been lying there for at least one year, the question was to buy or not to buy it. The price had dropped from R$ 250,00 to R$ 200,00 and I bought it for R$ 185,00 (USD 69.89) after making sure it passed the self test. When I removed the PVC film it was wrapped in, I found inside, to my surprise, it was like new: no personal marks, no scratches, totally mint (it lacks manual and case though). Actually it looks like it has never been used. Isn't that amazing?
When I bought my first 32SII new in box, two years ago, for about USD 80.00 and posted a message like this in comp.sys.hp48 someone complained: "rather than telling everybody about the bargain, you should submit a real contribution related to the 32Sii" (not his exact words). Though he had been kind of rude, I posted later an old program for the 15C which I had reconverted for the 32Sii. No one complained then, but no one replied...
Here it is:
Password game (HP32SII):
M01 LBL M
M02 5
M03 10^x
M04 4
M05 +
M06 STO i
M07 STO L
M08 x<>y
G01 LBL G
G02 10
G03 ÷
G04 ENTER
G05 FP
G06 10
G07 X
G08 STO (i)
G09 x<>y
G10 IP
G11 DSE i
G12 GTO G
G13 FS? 1
G14 GTO C
G15 SF 1
G16 FIX 1
G17 0
G18 STO K
A01 LBL A
A02 8.00401
A03 STO i
B01 LBL B
B02 RANDOM
B03 10
B04 X
B05 IP
B06 x=0?
B07 GTO B
B08 STO (i)
B09 DSE i
B10 GTO B
B11 RCL F
B12 x=y?
B13 GTO A
B14 RCL H
B15 x=y?
B16 GTO A
B17 RCL E
B18 x=y?
B19 GTO A
B20 RCL G
B21 x=y?
B22 GTO A
B23 RCL H
B24 x=y?
B25 GTO A
B26 x<>y
B27 RCL F
B28 x=y?
B29 GTO A
C01 LBL C
C02 RCL L
C03 STO i
C04 0
C05 STO I
C06 1
C07 STO J
C08 STO + K
D01 LBL D
D02 RCL A
D03 RCL E
D04 x=y?
D05 XEQ E
D06 RCL B
D07 RCL F
D08 x=y?
D09 XEQ E
D10 RCL C
D11 RCL G
D12 x=y?
D13 XEQ E
D14 RCL D
D15 RCL H
D16 x=y?
D17 XEQ E
D18 4
D19 RCL I
D20 x=y?
D21 GTO F
D22 0.1
D23 STO J
D24 RCL A
D25 RCL B
D26 STO A
D27 RCL C
D28 STO B
D29 RCL D
D30 STO C
D31 R^
D32 STO D
D33 DSE i
D34 GTO D
D35 RCL I
D36 STOP
D37 GTO M
E01 LBL E
E02 RCL J
E03 STO + I
E04 RTN
F01 LBL F
F02 CF 1
F03 STOP
F04 ALL
F05 RCL K
F06 RTN
R^ = (roll up)
size and checksum table
LBL SIZE CHKSUM
M 020.0 2229
G 027.0 5AE1
A 012.5 526D
B 043.5 1B53
C 012.0 F7FA
D 063.5 C8F7
E 006.0 A5A3
F 009.0 C7DF
The goal is to guess a 4digit password, ranging from 1234 to 9876, no repeated digits and
no "0" digits. The program gives you clues in the following format:
R.W
where "R" is the number of digits belonging to the secret password that are in their right positions and "W" is the number of digits that, although belonging to the password, are in wrong positions.
Program usage:
Enter your guessing and press XEQ M, the calculator will give you the first clue; enter your next guessing and press R/S until you get 4.0, meaning that you have found the correct password. Then press R/S again to see the number of tries and reset flag 1. You may also press XEG M between guesses instead of pressing R/S.
Example:
1234 XEQ M > 0.2
5678 R/S > 2.0
5612 R/S > 0.1
3178 R/S > 3.0
4178 R/S > 4.0 (correct guess!)
R/S > 5 (5 tries)
The original version of this game, which used some programming tricks to save memory steps was included in the TI 59 manual, by Texas Instruments. When I switched to HP 15C after my TI 59 was stolen, I soon converted it to run in the new calculator, a straightforward conversion as you can see  then I was not worried about in saving memory. An experienced RPN programmer would have made it shorter, but at the time this was the best I could do.
Password game (HP15C):
001 f LBL A 5 CHS 10^x 4 + STO I STO .2 x<>y
010 f LBL 0 10 ÷ ENTER f FRAC 10 X STO (i)
x<>y g INT
f DSE I GOTO 0
g F? 1 GTO 3
g SF 1 f FIX 0 STO .1
030 f LBL 1 8.00401 STO I
039 f LBL 2 f RAN# 10 X g INT
g x=0 GTO 2
STO (i)
f DSE I GTO 2
RCL 6 g TEST 5 GTO 1
RCL 8 g TEST 5 GTO 1
RCL 5 g TEST 5 GTO 1
RCL 7 g TEST 5 GTO 1
RCL 8 g TEST 5 GTO 1
x<>y RCL 6 g TEST 5 GTO 1
069 f LBL 3 RCL .2 STO I 0 STO 9
1 STO .0 STO + .1
077 f LBL 4 RCL 1 RCL 5 g TEST 5 GSB 5
RCL 2 RCL 6 g TEST 5 GSB 5
RCL 3 RCL 7 g TEST 5 GSB 5
RCL 4 RCL 8 g TEST 5 GSB 5
4 RCL 9 g TEST 5 GTO 6
.1 STO .0 RCL 1 RCL 2 STO 1
RCL 3 STO 2 RCL 4 STO 3 g R^ STO 4
f DSE I GTO 4
RCL 9 R/S
114 f LBL 5 RCL .0 STO + 9
118 f LBL 6 g CF 1 g SF 9 R/S g CF 9 f FIX 9 RCL .1
g RTN
R^ = (roll up)

Regards,
GWB
Edited: 29 Jan 2005, 4:54 p.m.
