(11C) Code guessing game
|
04-26-2018, 06:57 PM
(This post was last modified: 05-02-2018 08:23 PM by Dieter.)
Post: #4
|
|||
|
|||
RE: (11C) Code guessing game
(04-25-2018 06:18 PM)Rogier Wrote: Also known as "Mastermind". I wrote it somewhere around 1985. The calculator takes a number of 3-10 digits and up to 9 colours for you to guess. C starts a new game, D enters a guess. Result: number in the form a,b where a = number of digits with right colour, and b is the number of digits of the right colour which are in the right place. Or: number FIX9 > you guessed it. Ah, Mastermind / Bagels / Code Breaker – one of the first useful programs I wrote for the 34C back then. I used a different approach that stored the code digits in individual registers. And the code always consisted of four different colors. So let me add the following 11C/15C version to this thread. (15C commands in brackets, where required) Code: 001 LBL A Edit: changed the roles of R,0 and R7 for 11C compliance and removed an obsolete line. Hint for 15C users – you may replace the final lines after "GTO 0" with RCL 9 FIX 0 SF 9 RTN. If the code has been correctly guessed this yields a flashing display with the number of required guesses. ;-) You can also replace line 72...75 with DSE 0. The code length is set in line 005, change it as desired to something between 1 and 6. The number of different colors is set in line 010. Must be ≥ code length and ≤ 9. Default is a 4-digit code with each digit between 1 and 6. For your first attemps you may change this to a 3-digit code with 5 colors. [A] generates the code => 0,0 Enter your guess and press [R/S] or [B] => x,y Here x is the number of right colors in the right place, and y is the number of colors that are correct, but in the wrong position. Example: [A] => 0,0 Note: generated code is assumed to be 4532 1234 [B] => 1,2 1325 [B] => 0,3 3254 [B] => 0,4 2534 [B] => 2,2 2435 [B] => 1,3 4532 [B] => 4,0 06 So you finally got all 4 colors right and required 6 guesses. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)