Post Reply 
(17BII) Mastermind
04-30-2020, 08:45 PM (This post was last modified: 04-30-2020 08:51 PM by Nihotte(lma).)
Post: #1
(17BII) Mastermind
This time, it's a function for the HP17BII to search Mastermind code
I think my formula needs to be modify to run on the HP17BII+ because i use some multiply by 0
But it could run on HP27S too

The formula is close to the mechanism in use for the program running on the 12C

You should see the 3 steps :
1) generates the code to break (MIND) when N is 0
2) search for black positions between MIND and N (the user attempt) and prepares the white step
3) search for white positions among the remaining non black positions

There is the code :

Code:

EVAL =
IF( N=0 : 
      L( MIND : Σ ( I : 1 : NIVO : 1 : ALOG( I – 1 ) x INT( 1 + 9 x 
           L( RAN# : IF( FP( RAN# ) = 0 : ,5284163 : FP( RAN# x 997 ) ) ) ) ) )  x L( NB : 0) :
      L( TV : N ) x 0 + L( MD : MIND ) x 0 + L( NB : NB + 1 ) x 0 + L( TW : 0 ) + L ( MW : 0 ) +
      N +
,1 x ( Σ ( I : 1 : NIVO : 1 :
               IF( L( TI : INT( 10 x FP( G( TV ) ÷ L( DV : ALOG( I ) ) ) ) ) =
                     L( MI : INT( 10 x FP( G( MD ) ÷ G( DV ) ) ) ) : 1 :
                     L( TW : G( TW ) + ALOG( G( TI ) - 1 ) ) x 0 +
                     L( MW : G( MW ) + ALOG( G( MI ) - 1 ) ) x 0 ) ) ) +
,01 x ( Σ ( I : 1 : 9 : 1 :
                 MIN( INT( 10 x FP( G( TW ) ÷ L( DV : ALOG( I ) ) ) ) :
                           INT( 10 x FP( G( MW ) ÷ G( DV ) ) ) ) ) ) 
)

Example of use :

[CALC] → [EVAL] [ N ] [ NIVO ] [ RAN# ] [ MIND ] [ NB ]
DSP [ FIX ] 2 INPUT

,123456789 [RAN#]
5 [NIVO]
0 [N]
[EVAL] → EVAL=0,00

12399 [N] [EVAL] → EVAL=12399,05 : 0 black position but 5 white positions
99321 [N] [EVAL] → EVAL=99321,32 : 3 black positions and 2 white positions
93921 [N] [EVAL] → EVAL=93921,50 : all 5 positions found
RCL [NB] → NB=3,00 after 3 attempts

0 [N]
[EVAL] → EVAL=0,00
xxxxx [N] [EVAL] and so on
Find all posts by this user
Quote this message in a reply
04-30-2020, 10:08 PM
Post: #2
RE: (17BII) Mastermind
I left my 17BII at the office before being locked down... Sad

Juste because I’m curious:
Are you using a special mean to avoid being confused with all these parenthesis?
How much time did you spend for stabilizing the equation?
Find all posts by this user
Quote this message in a reply
05-01-2020, 07:34 AM (This post was last modified: 05-01-2020 07:39 AM by Nihotte(lma).)
Post: #3
RE: (17BII) Mastermind
(04-30-2020 10:08 PM)pinkman Wrote:  I left my 17BII at the office before being locked down... Sad

Juste because I’m curious:
Are you using a special mean to avoid being confused with all these parenthesis?
How much time did you spend for stabilizing the equation?

Hello pinkman !

That's right ! the system with all this parenthesis is not really easy.
After the first formula entry in the calculator, you can be sure you receive a INVALID EQUATION when pressing [CALC] !!!

But when you have made LISP program at school, that's a good training way !...

To control the equation, on the paper, i put a number under each pair of parentheses from the easy (and the very close) to the most distant. So i begin with the G( ) or L( ) and i put a 1 - 1 under each parenthesis and i finalize with the initial IF( and the ending )...

I mean, you are right : this step of validating the parentheses is the most painful and stressful!
And this is just a first step because you should have to play with the order of the variables on the the display...

But after all, when you run the formula, it's a little mixture of surprise and satisfaction !

Does anyone else have a specific approach to finalize all of these steps?!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)