Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
Okay, I have to revers my statement, I did find something, might be a memory leak.
The code posted below was run on a Pentium-III 1000 with 512MB RAM under Windows 2000 Server. It fails around the number combination 8,2,0,0 with an 'out-of-memory' error. Beforehand, memory consumption (as displayed in the Task Manager) is increasing constantly.
Additionally, in case of divisions by 0 , no 'division-by-zero' error is created but the division results in a mathematically incorrect '0'.
code:
BREAK ON cls
$rc = redirectoutput(@SCRIPTDIR+'\game24full.txt')
DIM $rc, $out, $result, $i1, $i2, $i3, $i4, $shellcommand, $ticks
$rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON') $rc=SRND(@MSECS)
? 'Game24 KiXtart Golf running under KiXtart v'@KIX ? 'Computer = Pentium III '+@MHZ+' and '+MEMORYSIZE()+' RAM' ? ''
$ticks=@TICKS
for $i1=0 to 9 for $i2=0 to 9 for $i3=0 to 9 for $i4=0 to 9 ? 'Numbers = '+$i1+', '+$i2+', '+$i3+', '+$i4 $out=Game24($i1,$i2,$i3,$i4) if $out ? 'Result = '+$out else ? 'No solution found' endif ? '' next next next next
? '' ? 'Time = '+(@TICKS-$ticks)+' ticks' ; end of the kiXtart Golf validation script
;! 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.
|