HP Forums

Full Version: (12C) Hi-Lo Game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi-Lo game, guess a number between 2 and 999 - usage: <NUMBER> R/S

Start with R/S - Diplay: 0
<guess> R/S - Diplay: -1 (guess to low), 1 (to high) or Number of attempts if guess was right

Code:

01 RCL 0           RAND / in advance save a seed between 0 and 1 to STO 0
02 9
03 LN
04 +
05 5
06 Y^X
07 FRAC            "random" number between 0 and 1
08 STO 0           save as new seed to STO 0
09 9
10 9
11 8
12 *
13 INTG
14 2
15 +               choose a number between 2-999 (because infos are -1/0/1)
16 STO 1           number to guess
17 CLX
18 STO 2           set counter to 0
19 R/S             <input>
20 1
21 STO + 2         increase counter
22 R down          input to x
23 RCL 1
24 -
25 x=0             0: guess is right
26 GTO 33          GOTO <OK>
27 ENTER
28 ENTER
29 *
30 SQRT            SQR / SQRT -> ABS(x)
31 /               -1: Assumption to low / +1: guessed to high
32 GTO 19          GOTO <input> - new guess
33 RCL 2           <OK> (show the number of attempts)
34 GTO 00

Note: the platinum requires 3 digits for the goto, i.e. gto 033 instead of gto 33
Very interesting program for a Hi-Lo Game especially for the HP-12C

Thank for this great program again and I try it already with my best guest count for 9 times.

Gamo
Wow, this game fits the last 34 lines on my 12C, starting at line 65.

Now the program memory is full Smile
Reference URL's