Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
This script is from Richard Howarth who asked me to post it for him. So, the credits go to Richard. please note that he implemented a recursive function with a KiXtart Golf Score of 404.
quote:
Game24 KiXtart Golf running under KiXtart v4.12 Beta 1 Computer = Pentium III 1000 and 511 RAM
Numbers = 1, 2, 3, 4 4.0*(3.0*(2.0/1)) = 24 The formula validated correctly
Numbers = 2, 2, 6, 8 8.0+(2.0*(6.0+2)) = 24 The formula validated correctly
Numbers = 4, 4, 6, 6 Correct answer answer, there is no solution to this combination
Numbers = 3, 3, 8, 8 8.0/(3.0-(8.0/3)) = 24 The formula validated correctly
Numbers = 0, 8, 2, 7 No solution found
Numbers = 3, 4, 7, 7 7.0-(4.0-(7.0*3)) = 24 The formula validated correctly
Numbers = 1, 2, 8, 9 9.0*(8.0/(2.0+1)) = 24 The formula validated correctly
Time = 2594 ticks
And the function is:
code:
;! Function game24($,$b,$c,$d) $game24=f(""+$+$b+$c+$d,"") EndFunction Function f($,$b) Dim $e,$x,$y,$z,$a If($) For $x=1 to Len($) $e=f(Left($,$x-1)+SubStr($,$x+1),$b+SubStr($,$x,1)) If $e $f=$e EndIf Next Else $e=Split("+ - * /") For Each $x In $e For Each $y In $e For Each $z In $e $=Left($b,1)+".0"+$x+"("+SubStr($b,2,1)+".0"+$y+"("+SubStr($b,3,1)+".0"+$z+Right($b,1)+"))" $z=Execute("$$a="+$) If "24"=$a $f=$ EndIf Next Next Next EndIf EndFunction
_________________________
There are two types of vessels, submarines and targets.
|