code:
function CDSorter($s, $m)
Dim $x, $z, $, $b
do
$ = split($s,",")
do
$b=0.
$z=""
for $x=0 to ubound($)
if $[$x]
$b = $b + $[$x]
$z=$z+","+($x+1)
endif
next
$[RND($x-1)]=0
until $b < $m
until $b > $m-1
$CDSorter=substr($z,2)
endfunction

code:
Average CD Length = 44.49
Average Gap = 0.51
Average Gap [%] = 1.14

KiXtart
KiXtart Version = 4.21 Release Candidate 1
KiXGolf Script = kixgolf_cd.kix

Computer
OS = Windows 2000 Professional
CPU = Intel Pentium III
Speed = 848 MHz
Memory = 511 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: CD Sorter
Processing Start = 2003/03/15 20:57:46.471
Processing End = 2003/03/15 20:58:04.329
Duration = 0000/00/00 00:00:17.857
# Loops = 1
# Processed CDs = 12
# Valid CDs = 12
# Full CDs = 0
KiXGolf Result = Valid CD Filling
KiXGolf Score = 195

Thank you for participating in KiXtart Golf!

_________________________
Home page: http://www.kixhelp.com/hb/