(17BII) Mastermind - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (17BII) Mastermind (/thread-14914.html) (17BII) Mastermind - Nihotte(lma) - 04-30-2020 08:45 PM 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 RE: (17BII) Mastermind - pinkman - 04-30-2020 10:08 PM I left my 17BII at the office before being locked down... 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? RE: (17BII) Mastermind - Nihotte(lma) - 05-01-2020 07:34 AM (04-30-2020 10:08 PM)pinkman Wrote:  I left my 17BII at the office before being locked down... 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?!