Gerry,

Not a very "heavyweight" program, but here is "CodeBreaker" for the 15C. Play is as described here. It runs painfully slow on a 15c classic. (I officially claim priority for first referring to the original 15c as the "15c classic".) It is quite fast on the 15c LE.

I have tried everything I can think of to make the program shorter. I had one idea that saved one step but would likely run slower, not that it matters on the 15c LE. Suggested improvments would be welcome!

Step Function Keycode Comment

001 LBL C 42,21,13 Label C for "Code Breaker"

002 Cl REG 42 34 clears all registers, mostly to get zeroes in 1 - 4, .0

003 FIX 1 42, 7, 1 set display mode Fix 1 so scores are presented as x.x

004 1 1 enter 1 for first digit of 10

005 0 0 enter 0 for second digit of 10

006 STO 6 44 6 Store constant 10 in register 6

007 4 4 enter 4

008 STO I 44 25 Store for in I for loop index and indirect storage.

009 LBL 2 42,21, 2 Label 2

010 RAN# 42 36 generate random number

011 RCL x 6 45,20, 6 Multiply times 10 to get a digit left of decimal point

012 INT 43 44 drop fractional portion

013 RCL 1 45 1 Recall register 1

014 TEST 5 43,30, 5 compare randomly generated digit to existing secret number digit

015 GTO 2 22 2 go to random number generator if random number is equal to any existing digit of secret number

016 x<>y 34 swap if not equal to get randomly generated digit back for next test

017 RCL 2 45 2 Recall register 2

018 TEST 5 43,30, 5 compare randomly generated digit to existing secret number digit

019 GTO 2 22 2 go to random number generator if random number is equal to any existing digit of secret number

020 x<>y 34 swap if not equal to get randomly generated digit back for next test

021 RCL 3 45 3 Recall register 3

022 TEST 5 43,30, 5 compare randomly generated digit to existing secret number digit

023 GTO 2 22 2 go to random number generator if random number is equal to any existing digit of secret number

024 x<>y 34 swap if not equal to get randomly generated digit back for next test

025 RCL 4 45 4 Recall register 4

026 TEST 5 43,30, 5 compare randomly generated digit to existing secret number digit

027 GTO 2 22 2 go to random number generator if random number is equal to any existing digit of secret number

028 x<>y 34 swap if not equal to get randomly generated digit back for next test

029 STO (i) 44 24 If random number is not equal to any existing digit, store in register pointed to by I

030 DSE I 42, 5,25 Decrement index

031 GTO 2 22 2 Go back to random number generator to store next digit

032 LBL 3 42,21, 3 Label 3

033 RCL 8 45 8 Recall register 8 to get original guess back for guessing portion

034 RCL .0 45 .0 Recall .0, count of guesses for guessing portion

035 RCL 5 45 5 Recall 5, score of guess for guessing portion

036 STOP 31 Stop

037 STO 8 44 8 Store 4 digit guess in register 8

038 STO 9 44 9 Store 4 digit guess in register 9

039 Cl x 43 35 Clear x for 0 in x

040 STO 5 44 5 Store in register 5, which will hold score for the current guess

041 4 4 Enter 4

042 STO I 44 25 Store 4 in I for loop index and indirect recalling.

043 LBL 8 42,21, 8 Label 8

044 RCL 9 45 9 Recall guess

045 RCL / 6 45,10, 6 Divide guess by 10

046 STO 9 44 9 Store back in register 9

047 FRAC 42 44 Take fractional part

048 RCL x 6 45,20, 6 Multiply times 10 to get a digit left of decimal point

049 INT 43 44 drop fractional portion

050 RCL (i) 45 24 Recall register pointed to by I

051 TEST 5 43,30, 5 Compare to digit extracted from guess for the I position

052 GTO 4 22 4 If equal, go to scoring for correct digit in correct location

053 x<>y 34 Swap to get extracted digit back

054 RCL 4 45 4 Recall digit 4

055 TEST 5 43,30, 5 Compare to extracted digit from guess

056 GTO 5 22 5 if equal, go to scoring for correct digit in incorrect location

057 x<>y 34 Swap to get extracted digit back

058 RCL 3 45 3 Recall digit 3

059 TEST 5 43,30, 5 Compare to extracted digit from guess

060 GTO 5 22 5 if equal, go to scoring for correct digit in incorrect location

061 x<>y 34 Swap to get extracted digit back

062 RCL 2 45 2 Recall digit 2

063 TEST 5 43,30, 5 Compare to extracted digit from guess

064 GTO 5 22 5 if equal, go to scoring for correct digit in incorrect location

065 x<>y 34 Swap to get extracted digit back

066 RCL 1 45 1 Recall digit 1

067 TEST 5 43,30, 5 Compare to extracted digit from guess

068 GTO 5 22 5 if equal, go to scoring for correct digit in incorrect location

069 0 0 enter 0 to indicate digit not in number

070 GTO 6 22 6 Go to scoring

071 LBL 4 42,21, 4 Label 4

072 1 1 Enter 1 for correct digit in correct location

073 GTO 6 22 6 Go to scoring

074 LBL 5 42,21, 5 Label 5

075 . 48 enter decimal point

076 1 1 enter 1 (for .1) for guess digit in number in incorrect location

077 LBL 6 42,21, 6 Label 6

078 STO + 5 44,40, 5 Add 1, .1 or 0 to score

079 DSE I 42, 5,25 Decrement index

080 GTO 8 22 8 Go to Label 8 to extract next guess digit

081 1 1 Enter 1

082 STO + .0 44,40,.0 Add to register .0, count of guesses

083 GTO 3 22 3 Go to 3

*Edited: 6 Sept 2011, 9:46 p.m. *