#149285 - 2005-10-06 03:01 AM
Re: KiXgolf: Fragmentation - Public Coding
|
maciep
Korg Regular
Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
|
More with Allen's code
Code:
function f($) dim $h,$c,$o,$t,$a $f=ubound($) for $c=0 to $f for $h=$c+1 to $f $a=$[$c]+$[$h] if len($a)=2*len(join($,""))/($f+1) $o=$o + a +$a+ a+ $[$h]+$[$c] endif next next for each $ in split($o,a) $h=ubound(split($o,$)) if $h>$t $t=$h $f=$ ;endif ;next endfunction
Quote:
KiXtart Engine KiXtart Version = 4.50 KiXGolf Script = kixgolf_fragmentation.kix
Computer OS = Windows XP Professional CPU = Intel(R) Xeon(TM) Speed = 2790 MHz Memory = 1024 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXGolf Score Tournament = Fragmentation Processing Start = 2005/10/05 20:40:41.411 Processing End = 2005/10/05 20:40:41.661 Duration = 0000/00/00 00:00:00.250 # Tests Run = 180 # Tests Passed = 180 # Tests Failed = 0 Result = passed KiXGolf Score = 221
|
Top
|
|
|
|
#149286 - 2005-10-06 03:07 AM
Re: KiXgolf: Fragmentation - Public Coding
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
Yeah Baby!
|
Top
|
|
|
|
#149292 - 2005-10-06 06:08 AM
Re: KiXgolf: Fragmentation - Public Coding
|
maciep
Korg Regular
Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
|
Here's another apporach using rnd() that just came to me. Golf away....
Code:
Function f($) dim $u,$i,$j $u=ubound($) while 1 dim $x[$u],$c $f='' for $j=1 to 2*len(join($,""))/($u+1) $f=$f+rnd(1) next for $j=0 to $u for $i=0 to $u if 0=($i=$j)+ $x[$i] + $x[$j]+ ($[$j]+$[$i]<>$f) $c=$c+2 $x[$i]=1 $x[$j]=1 if $c>$u exit ;endif ;endif ;next ;next ;loop endfunction
Quote:
KiXtart Engine KiXtart Version = 4.50 KiXGolf Script = kixgolf_fragmentation.kix
Computer OS = Windows XP Professional CPU = Intel(R) Xeon(TM) CPU 2.80GHz Speed = 2790 MHz Memory = 1024 MB
KiXGolf Scoring Engine Scoring Engine = 3.0.3
KiXGolf Score Tournament = Fragmentation Processing Start = 2005/10/05 23:46:34.779 Processing End = 2005/10/05 23:47:04.670 Duration = 0000/00/00 00:00:29.891 # Tests Run = 180 # Tests Passed = 180 # Tests Failed = 0 Result = passed KiXGolf Score = 217
|
Top
|
|
|
|
#149296 - 2005-10-06 02:58 PM
Re: KiXgolf: Fragmentation - Public Coding
|
maciep
Korg Regular
Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
|
actually, i think i'm the leader with the new code i posted...or maybe i missed something.
And here is the code that 'found' Allen's flaw. Logically, it should work the same as his original, but it fails.
Code:
function f($) dim $h,$c,$o,$t $f=ubound($) for $c=0 to $f for $h=0 to $f $t = a+$[$c]+$[$h] if len($t)=2*len(join($))/($f+1) and $h<>$c $o=$o+$t endif next next for each $ in split($o,a) $h=ubound(split($o,$)) if $h>$t $t=$h $f=$ endfunction
|
Top
|
|
|
|
#149303 - 2005-10-06 04:02 PM
Re: KiXgolf: Fragmentation - Public Coding
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
ah that sucks... ...
So now I need to figure out why it passed test two when I change the order around.
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 920 anonymous users online.
|
|
|