I'm a little confused as to how the logistics for this program should work, so any help would be greatly appriciated.
First, a simple explaination of what I'm trying to do: Make a PHP program to solve (and eventually generate) problems from/for the card game "24".
What the heck is 24?
24 is a mathmatical game in which players try to add, subtract, multiply or divide four numbers to make 24. Parenthesis in any place are allowed. For example, the numbers 8,5,2,1. You're trying to make 24, so you would do:
(5-2) = 3,
3*8=24
Note, that was very simple. Anyways, my delima is how to make the program work logisticly: It needs to be able to check a set of four numbers to see if they work, and to do so, it needs to check adding, subtracting, multiplying, and dividing in any order, and then deal with the fact that for every combination of numbers and operators, parenthesis can be thrown in anywhere. This comes up to over 419,000 possible combinations, without the parenthesis. And then there's the catch that you can sometimes solve a problem multiple ways, and I would like all of the possible solutions displayed. So, what is there to do? Making a webserver, albeit a fast one, run at least 1 million calculations seems like overkill. Is there a shorter way to do this? And even if there isn't, I also would appriciate some pseudo code. I'm a little confused as to how all of the loops and if's (or whatever else one would use) fit togeather.
Again, any help would be GREATLY appriciated.