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


Average CD Length = 44.41
Average Gap = 0.59
Average Gap [%] = 1.30

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

Computer
OS = Windows 2000 Professional
CPU = Intel Pentium III
Speed = 797 MHz
Memory = 375 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: CD Sorter
Processing Start = 2003/03/16 02:55:40.369
Processing End = 2003/03/16 02:56:10.873
Duration = 0000/00/00 00:00:30.503
# Loops = 1
# Processed CDs = 12
# Valid CDs = 12
# Full CDs = 0
KiXGolf Result = Valid CD Filling
KiXGolf Score = 201

Thank you for participating in KiXtart Golf!
_________________________
!

download KiXnet