I am a bit late since my home machine still isn't up to snuff. I actually lowered my score to 653. I might have tried to go lower but I couldn't seem to generate any method that worked consistently. I especially had trouble with Jooel's suggestion of testing the script with a large number of random selection. This code passes Jens test & seems to works properly for a large number of random selections but if I change the order of the permutations (i.e. use '+ - / *' instead of '+ - * /') it still fails.
code:
Function Game24($i,$j,$k,$l)
dim $a, $b, $c, $d, $e, $f, $g, $h, $m, $s, $t, $u, $v, $n[3], $[14], $o[3]
$n=$i,$j,$k,$l
$o = split('+ - * /')
$s='cdbl('
$u=')'
for $a=0 to 3
for $b=0 to 3
for $c=0 to 3
for $d=0 to 3
if $a<>$b&$a<>$c&$a<>$d&$b<>$c&$b<>$d&$c<>$d
$[1]=$s+$n[$a]+$u
$[5]=$s+$n[$b]+$u
$[9]=$s+$n[$c]+$u
$[13]=$s+$n[$d]+$u
for each $e in $o
for each $f in $o
for each $g in $o
$[3]= $e
$[7]= $f
$[11]= $g
for $h=0 to 6
for $m=0 to 7
$[2*$m]=''
next
if $h=1 or $h=3 or $h=6 $[0]='(' endif
if $h=2 or $h=4 $[4]='(' endif
if $h=3 or $h=6 $[6]=')' endif
if $h=5 or $h=6 $[8]='(' endif
if $h=1 or $h=4 $[10]=')' endif
if $h=2 or $h=5 or $h=6 $[14]=')' endif
$t=Join($)
$m=execute('$$v=$t')
if 24=$v
$Game24=Join($)
return
endif
next
next
next
next
endif
next
next
next
EndFunction
PS: Did you all verify that your code actually generates all the combinations & did you compare your results with Madruga's analysis? Richard's code is a thing of beauty but it doesn't generate all the possible combinations. Richard assumes the nested brackts "a (b(c d))" can be morphed into all possible solutions but it cannot be morphed into several of the unique solutions found by Madruga.
I think validating our results is a serious challange in this competition.