[thechat] Programming Problem
Paul Cowan
paul at wishlist.com.au
Thu Nov 8 23:21:09 CST 2001
some handsome fool wrote:
> Rather ugly, but would work. Might try doing it over the weekend..
> interesting idea.
Hmm.. just hit me: good idea here would be to use JavaScript.. then you can
build a string and call eval() (PHP might have similar.. don't know)
thus.. my loop from earlier, then
str1 = a + op1 + b + op2 + c + op3 + d
str2 = '(' + a + op1 + b + ')' op2 + c + op3 + d
str3 = a + op1 + '(' + b + op2 + c + ')' + op3 + d
if (eval(str1) == 24) {
// print str1
}
...
use arrays or something to make it nicer, obviously.
Paul
More information about the thechat
mailing list