Great stuff - good thinking.

code:
Average CD Length = 44.21
Average Gap = 0.79
Average Gap [%] = 1.77

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

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

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: CD Sorter
Processing Start = 2003/03/18 11:16:47.098
Processing End = 2003/03/18 11:17:49.758
Duration = 0000/00/00 00:01:02.660
# Loops = 1
# Processed CDs = 13
# Valid CDs = 13
# Full CDs = 0
KiXGolf Result = Valid CD Filling
KiXGolf Score = 163

Thank you for participating in KiXtart Golf!

code:
function CDSorter($a, $b)
dim $p
do
dim $u, $, $t
$p = -0.5 + $b
for each $t in split($a, ",")
$u=1+$u
if rnd(2) & $p > $t
$p = $p - $t
$ = $ + "," + $u
endif
next
$CDSorter = substr($,2)
until 0=$p
endfunction

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