
November 3rd, 2012, 04:49 PM
|
|
|
|
PHP-General - Countdown conundrum - game - need pointers?
Strictly not php, but I will be using php.
game works like this:
You ask for 6 numbers (2 big numbers from: 25, 50, 75, 100) ,and 4 small numbers (1-10) a random target is chosen which you have to reach using the numbers and + - / *.
I am trying to emulate this via php.
Now i tried to code like a human would like:
target/big number. if no remainder.. done. if remainder, try to use other numbers to get that remainder..
lots of if/elsif..
Then i got fed up and i just use a script to pick between 1-6 numbers, random signs and then eval the numbers/signs to see the result. if result = target i stop looping.
It works most of the time but it is pure trial and error.
Is there a better way of approaching?
Please note: i am not looking for solution but rather pointers to how i should approach this.
|