#99624 - 2003-03-15 08:58 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
code:
function CDSorter($s, $m) Dim $a, $b, $x, $z, $ do $b = split($s,",") $a = ubound($b) do $b[RND($a)]=0 $=0.0 for each $x in $b $ = $ + $x next until $ < $m until $ > $m-1 for $=0 to $a if $b[$] $z=$z+","+($+1) endif next $CDSorter=substr($z,2) endfunction
code:
CD #1 Title = 70's Super Funk Song #s = 1,7,8,9,10,14,16,19,20 CD Length = 44.6711 CD Gap = 0.3289 CD Gap [%] = 0.7309 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:48.734 Processing End = 2003/03/15 14:43:48.744 Duration = 0000/00/00 00:00:00.010
CD #2 Title = Partridge Family Unlimited Song #s = 1,2,9,12,18 CD Length = 44.9179 CD Gap = 0.0821 CD Gap [%] = 0.1824 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:48.754 Processing End = 2003/03/15 14:43:48.794 Duration = 0000/00/00 00:00:00.040
CD #3 Title = Three Tenors in Antarctica, Again! Song #s = 2,3,4,6,8,9,11,12,14,15 CD Length = 44.9741 CD Gap = 0.0259 CD Gap [%] = 0.0576 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:48.804 Processing End = 2003/03/15 14:43:48.834 Duration = 0000/00/00 00:00:00.030
CD #4 Title = Support Your Local KiXGolfer Song #s = 11,27 CD Length = 44.2000 CD Gap = 0.8000 CD Gap [%] = 1.7778 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:48.844 Processing End = 2003/03/15 14:43:49.375 Duration = 0000/00/00 00:00:00.531
CD #5 Title = ABBA Bubba! Song #s = 1,2,3,5,7,10,12,13,15,18,19,23,26,28,29,30 CD Length = 44.8102 CD Gap = 0.1898 CD Gap [%] = 0.4218 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.375 Processing End = 2003/03/15 14:43:49.405 Duration = 0000/00/00 00:00:00.029
CD #6 Title = Songs You Never Wanted Your Teenage Daughter To Know About Song #s = 1,2,6,7,8 CD Length = 44.5000 CD Gap = 0.5000 CD Gap [%] = 1.1111 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.415 Processing End = 2003/03/15 14:43:49.415 Duration = 0000/00/00 00:00:00.000
CD #7 Title = Moon Rocks! Song #s = 2,4,12,13,14,16,18,21,23,24,28,30,31,34,36 CD Length = 44.4539 CD Gap = 0.5461 CD Gap [%] = 1.2136 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.415 Processing End = 2003/03/15 14:43:49.455 Duration = 0000/00/00 00:00:00.040
CD #8 Title = Ruud's Favs Song #s = 1,3,5,6,7,8,9,10,12,13,14,16,17,19,20 CD Length = 44.1609 CD Gap = 0.8391 CD Gap [%] = 1.8647 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.465 Processing End = 2003/03/15 14:43:49.465 Duration = 0000/00/00 00:00:00.000
CD #9 Title = MTV Presents: KiXtart Rulez! Song #s = 1,3,8,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26, 27,28,29,30,31,32,33,34,35,36,38,39,40,41,43,45,46,47,50 CD Length = 44.2549 CD Gap = 0.7451 CD Gap [%] = 1.6558 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.475 Processing End = 2003/03/15 14:43:49.485 Duration = 0000/00/00 00:00:00.010
CD #10 Title = Songs From the Programmer's Abyss Song #s = 1,3,4,5,7,8,9,10,13,14,15,16,17,20,21,24,26,27,29,31, 32,33,34,35,36,37,38,40,42,43,44,46,47,48,50 CD Length = 44.4987 CD Gap = 0.5013 CD Gap [%] = 1.1140 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.485 Processing End = 2003/03/15 14:43:49.495 Duration = 0000/00/00 00:00:00.010
CD #11 Title = Just Noise (100% Pure White Noise) Song #s = 36,57,61,66,69 CD Length = 44.2500 CD Gap = 0.7500 CD Gap [%] = 1.6667 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:43:49.505 Processing End = 2003/03/15 14:44:00.482 Duration = 0000/00/00 00:00:10.977
CD #12 Title = Cazy Jens And the KIXGolfers Song #s = 3,14,18,41,42,43,51,54,56,92,100 CD Length = 44.0777 CD Gap = 0.9223 CD Gap [%] = 2.0496 Req. CD Length = 44.0000 Result = CD has been filled Processing Start = 2003/03/15 14:44:00.482 Processing End = 2003/03/15 14:44:00.682 Duration = 0000/00/00 00:00:00.199
Average CD Length = 44.48 Average Gap = 0.52 Average Gap [%] = 1.15
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 14:29:09.753 Processing End = 2003/03/15 14:44:00.682 Duration = 0000/00/00 00:14:50.929 # Loops = 100 # Processed CDs = 12 # Valid CDs = 12 # Full CDs = 0 KiXGolf Result = Valid CD Filling KiXGolf Score = 207 Thank you for participating in KiXtart Golf!
|
Top
|
|
|
|
#99625 - 2003-03-15 08:59 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
This is Richard Howarth's contribution. He asked me to post it as he won't be available to do it himself
code:
; begin CD Sorter ; ; Areas for improvement: ; 1) Convert values to integer. This should speed things up hugely. ; ; 2) Presort the list by track length. This will limit the iterations as will be able to discard ; all iterations once the maximum length has been exceeded. This requires the list to be in ; DESCENDING order, and add return values to abort both the recursion and the iteration when ; the track list gets too large. ;! Function CDSorter($s, $) ; $s=comma separated list of all track lengths, $=media size. If IsDeclared($c)=0 ; Redclaring a global will cause a run time error. Global $c,$g,$t ; Globals: $c=Best List, $g=Smallest Gap, $t=track list array. EndIf $t=Split($s,",") ; Convert CD list to array. $g=$ ; Record maximum gap as worst case. a(0.+$,"",Ubound($t)) ; Start recursive routine from highest track, force starting gap to floating point. $CDSorter=SubStr($c,2) ; Assign best list found, dropping the redundant comma. EndFunction Function a($f,$l,$) ; $f=Parents gap, $l=current track "path", $=track in array to start looking. Dim $n,$m ; $n=Gap for each iteration, $m=track list for each iteration. While $ ; Iterate loop for each element to the left of the parent element. If $g<0.0001 Return EndIf ; "1" for quick, "0.0001" for best fit, remove for shortest code and longest run time. $n=$f-$t[$] ; Decrease current gap by the length of this track. If $n>=0 ; Only continue if current gap is not negative (track list too long) $m=$l+","+($+1) ; Append current track to parents track list If $n<$g ; Is the new gap smaller than the best found so far? $g=$n ; Yes it is. Ok, Record this smaller gap, and $c=$m ; record the better track list. EndIf a($n,$m,$-1) ; See if the tracks to the left of this one can reduce the gap further. EndIf $=$-1 Loop EndFunction ;! ;!
; end CD Sorter
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#99626 - 2003-03-15 09:04 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Alternatate methodology using the "Scripting.Dictionary" object. Thought is was fun and it could have competed if M$ did not have such long object and method names.
code:
function CDSorter($T, $m) ; score 240 Dim $b, $c, $ do $c = split($T,",") $b = CreateObject("Scripting.Dictionary") for $=0 to ubound($c) $b.add($+1, $c[$]) next do $b.Remove(RND($)) ;remove the '$' above in RND($) to save a stroke, ;but this will dramatically increase runtime. $=0.0 for each $c in $b.items $ = $ + $c next until $ < $m until $ > $m-1 $CDSorter=join($b.keys,",") endfunction
code:
Average CD Length = 44.45 Average Gap = 0.55 Average Gap [%] = 1.23
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 15:06:54.535 Processing End = 2003/03/15 15:07:22.949 Duration = 0000/00/00 00:00:28.413 # Loops = 1 # Processed CDs = 12 # Valid CDs = 12 # Full CDs = 0 KiXGolf Result = Valid CD Filling KiXGolf Score = 240
|
Top
|
|
|
|
#99627 - 2003-03-15 09:12 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
the 244 from me. won't post the long info as it's already there somewhere. code:
function CDSorter($, $m) dim $k,$a,$c,$i,$o,$l $i=split(","+$,",") for $k=0 to ubound($i) for each $ in split($c) $a=$+","+$k $=0. for each $l in split($a,",") $=$+$i[$l] next if $<=$m & $o-$<$i[$k] if $>$o $o=$ $CDSorter=substr($a,2) endif $c=$c+$a+" " endif next next endfunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#99628 - 2003-03-15 09:23 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
and 206.
code:
function CDSorter($s, $m) Dim $a, $x, $z, $, $b do $b = split($s,",") $a = ubound($b) do $b[RND($a)]=0 $=0. for each $x in $b $ = $ + $x next until $ < $m until $ > $m-1 for $=0 to $a if $b[$] $z=$z+","+($+1) endif next $CDSorter=substr($z,2) endfunction
quote: Average CD Length = 44.45 Average Gap = 0.55 Average Gap [%] = 1.22
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/15 22:28:27.395 Processing End = 2003/03/15 22:28:32.762 Duration = 0000/00/00 00:00:05.366 # Loops = 1 # Processed CDs = 12 # Valid CDs = 12 # Full CDs = 0 KiXGolf Result = Valid CD Filling KiXGolf Score = 206 Thank you for participating in KiXtart Golf!
_________________________
!download KiXnet
|
Top
|
|
|
|
#99629 - 2003-03-15 09:27 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Arrggghhhh!
|
Top
|
|
|
|
#99631 - 2003-03-15 10:14 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
MightyR1
MM club member
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
My contribution...
Loops=100 and fast!
Take a look at my CPU info & Speed; a bug in KiX???
quote:
Average CD Length = 44.60 Average Gap = 0.40 Average Gap [%] = 0.88
KiXtart KiXtart Version = 4.20 KiXGolf Script = kixgolf_cd.kix
Computer OS = Windows XP Professional CPU = Mobile Intel(R) Pentium(R) 4 - M CPU 2.20GHz Speed = 1196 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 22:36:23.772 Processing End = 2003/03/15 22:38:59.997 Duration = 0000/00/00 00:02:36.225 # Loops = 100 # Processed CDs = 12 # Valid CDs = 12 # Full CDs = 0 KiXGolf Result = Valid CD Filling KiXGolf Score = 427 Thank you for participating in KiXtart Golf!
code:
Function CDSorter($a, $b) Dim $n,$,$c,$d,$x,$j ;! Break on ;! $a=Split($a,',') $n=Ubound($a) $x=$a For $=0 to $n $x[$]=1+$ Next For $=1 to $n $c=0.+$a[$-1] $d=$x[$-1] If 0.+$a[$] > $c $a[$-1]=0.+$a[$] $x[$-1]=$x[$] $a[$]=$c $x[$]=$d $=0 EndIf Next For $=0 to $n $c=0.+$a[$] $d=','+$x[$] If $c > $b-1 AND $c < $b $=$n Else For $j=$+1 to $n $c=$c+$a[$j] If $c < $b $d=$d+','+$x[$j] If $c > $b-1 $j=$n EndIf Else $c=$c-$a[$j] $j=$j+1 EndIf Next If $c > $b-1 AND $c < $b $=$n EndIf EndIf Next $CDsorter=SubStr($d,2) EndFunction
[ 15. March 2003, 22:34: Message edited by: MightyR1 ]
_________________________
Greetz, Patrick Rutten
- We'll either find a way or make one... - Knowledge is power; knowing how to find it is more powerful... - Problems don't exist; they are challenges...
|
Top
|
|
|
|
#99636 - 2003-03-16 01:52 AM
Re: KiXGolf: CD Sorter, Part II (public)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
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
|
Top
|
|
|
|
#99637 - 2003-03-16 01:58 AM
Re: KiXGolf: CD Sorter, Part II (public)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
k, make it 200
code:
function CDSorter($s, $m) Dim $x, $z, $, $b do $ = split($s,",") do $[RND(ubound($))]=0 $b=0. $z="" for $x=0 to ubound($) $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.54 Average Gap = 0.46 Average Gap [%] = 1.03
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 03:01:47.116 Processing End = 2003/03/16 03:02:35.005 Duration = 0000/00/00 00:00:47.888 # Loops = 1 # Processed CDs = 12 # Valid CDs = 12 # Full CDs = 0 KiXGolf Result = Valid CD Filling KiXGolf Score = 200 Thank you for participating in KiXtart Golf!
_________________________
!download KiXnet
|
Top
|
|
|
|
#99638 - 2003-03-16 02:53 AM
Re: KiXGolf: CD Sorter, Part II (public)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
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!
|
Top
|
|
|
|
#99639 - 2003-03-16 03:48 AM
Re: KiXGolf: CD Sorter, Part II (public)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
code:
function CDSorter($s, $m) Dim $x, $, $b do $ = split($s,",") do $b=0. Dim $z for $x=0 to ubound($) if $[$x] $b = $b + $[$x] $z=$z+","+($x+1) endif next $[RND($x-1)]=0 $CDSorter=substr($z,2) until $b < $m until $b > $m-1 endfunction
code:
Average CD Length = 44.45 Average Gap = 0.55 Average Gap [%] = 1.22
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 21:53:05.731 Processing End = 2003/03/15 21:53:22.948 Duration = 0000/00/00 00:00:17.217 # Loops = 1 # Processed CDs = 12 # Valid CDs = 12 # Full CDs = 0 KiXGolf Result = Valid CD Filling KiXGolf Score = 192 Thank you for participating in KiXtart Golf!
|
Top
|
|
|
|
#99641 - 2003-03-16 05:05 PM
Re: KiXGolf: CD Sorter, Part II (public)
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Jooel, good job! Looks tough to beat, but I will study it for a while.
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 980 anonymous users online.
|
|
|