Page 1 of 5 12345>
Topic Options
#149264 - 2005-10-06 01:09 AM KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
"Gentlemen, please post your code!" -Jens
_________________________
!

download KiXnet

Top
#149265 - 2005-10-06 01:12 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and here is my 229:
Code:

Function F($o)
Dim $,$r,$e,$c,$l
$c=1+Ubound($o)
$l = 2*Len(Join($o,$))/$c
Do
do
$f = Rnd($c-1)
until 0 = InStr($r,a+$f+a) - Len($+$o[$f]) mod $l * $e
$r = a+$f+a+$r
$e = ~ $e
$ = $ + $o[$f]
Until Len($) = $l * $c / 2
$f = Left($, $l)
If Join(Split($,$f),"") $f=f($o)
EndFunction

_________________________
!

download KiXnet

Top
#149266 - 2005-10-06 01:12 AM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
With a score of 225...

Code:

Function F($d)
dim $u,$,$i,$j,$a[255],$b[255,15],$t[255]
$u = ubound($d)
for $j=0 to $u
for $i=0 to $u
$F=$d[$j]+$d[$i]
$a[$u*$j+$j+$i]=$F
$=ascan($a,$F)
if 0=$b[$,$j] + $b[$,$i] + ($i=$j)
$b[$,$j]=1
$b[$,$i]=1
$t[$]=$t[$]+2
if $t[$]=$u+1
exit
;endif
;endif
;next
;next
EndFunction


Top
#149267 - 2005-10-06 01:43 AM Re: KiXgolf: Fragmentation - Public Coding
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Code:
 
;255
function f($)
dim $h,$c,$o,$t,$a
$f=ubound($)
do
$h=$c+1
do
$a=$[$c]+$[$h]
if len($a)=2*len(join($,""))/($f+1)
$o=$o + " "+$a+" "+$[$h]+$[$c]
endif
$h=$h+1
until $h>$f
$c=$c+1
until $c=$f
$o=trim($o)
for each $ in split($o)
$h=ubound(split($o,$))
if $h>$t
$t=$h
$f=$
endif
next
endfunction


Top
#149268 - 2005-10-06 01:45 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
maciep dude...
you always have a way to suprise.
your code is once again so wicked that I must stare it more than 5 minutes to understand what you do.

nice!
_________________________
!

download KiXnet

Top
#149269 - 2005-10-06 01:50 AM Re: KiXgolf: Fragmentation - Public Coding
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Quote:


;endif
;endif
;next
;next






okay... is kixtart still reading these as endif's and next's... and since this is a comment is the scoring engine ignoring them?

Top
#149270 - 2005-10-06 01:54 AM Re: KiXgolf: Fragmentation - Public Coding
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
heheee ....

Code:

;endif
;endif
;next
;next



You are a dirty dawg Eric ... thats why I like yah.

Top
#149271 - 2005-10-06 01:54 AM Re: KiXgolf: Fragmentation - Public Coding
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
KiX doesn't read them, it infers them and yes comments are ignored in scoring.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149272 - 2005-10-06 01:56 AM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
My code? I've been working with a group of developers from NASA to try and figure out wtf your $e var is doing

Basically my code, just enumerates all possible combinations (for loops), keeps a count of how many times i've 'seen' that combination ($t array), ensures that a 'file piece' is only used once per combination ($b array) and also make sure i don't create a combination by adding a 'file piece' to itself - that would be impossible ($i=$j stuff)

if every piece can be used for the same combination (count=ubound+1) - we're done.

Top
#149273 - 2005-10-06 01:56 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Code:

Function F($d)
dim $u,$,$i,$j,$a[255],$b[255,15],$t[255]
$u = ubound($d)
for $j=0 to $u
for $i=0 to $u
$F=$d[$j]+$d[$i]
$a[$u*$j+$j+$i]=$F
$=ascan($a,$F)
if 0=$b[$,$j] + $b[$,$i] + ($i=$j)
$b[$,$j]=1
$b[$,$i]=1
$t[$]=$t[$]+2
if $t[$]>$u
exit
;endif
;endif
;next
;next
EndFunction


Code:

KiXtart Engine
KiXtart Version = 4.50 (WKIX32.EXE)
KiXGolf Script = kixgolf_fragmentation.kix

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

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXGolf Score
Tournament = Fragmentation
Processing Start = 2005/10/06 02:34:45.393
Processing End = 2005/10/06 02:34:47.616
Duration = 0000/00/00 00:00:02.222
Used Processor Time = 00:00:01.812
# Tests Run = 180
# Tests Passed = 180
# Tests Failed = 0
Result = passed
KiXGolf Score = 223

Thank you for participating in KiXtart Golf!
Press any key to continue...

_________________________
!

download KiXnet

Top
#149274 - 2005-10-06 01:58 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and, yes we are
_________________________
!

download KiXnet

Top
#149275 - 2005-10-06 01:59 AM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Shawn, it's just the dawg in me
Top
#149276 - 2005-10-06 02:01 AM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
nice. i knew you'd be able to chop away at that.
Top
#149277 - 2005-10-06 02:05 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the $e-var?

well, it just goes from true to false, kinda.
and if it's false, happens [something] mod 0 that is always 0.

so in english, the line:
Code:

until 0 = InStr($r,a+$f+a) - Len($+$o[$f]) mod $l * $e


keeps the loop going on until a random number is met that is not already used and if doing a even loop, checks if file-length is matched.
that is, can't accept "01" and "101" as the first 2 pieces if $length is 10.
as that would break my left() (and it did in the beginning)
instead, the code keeps looking until it finds a pair that has the required length.
_________________________
!

download KiXnet

Top
#149278 - 2005-10-06 02:15 AM Re: KiXgolf: Fragmentation - Public Coding
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Code:

;endif
;endif
;next
;next



I'm amazed that works. I tried removing the last endif but it barfed because of the next after it. It never crossed my mind to remove the next. Brilliant! That would have dropped my score to 246.

[edit]... Les where did you come from... I don't see your score anywhere


Edited by Allen (2005-10-06 02:17 AM)

Top
#149279 - 2005-10-06 02:17 AM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
And now you know. In the last tourney, shawn and i both employed that forgiving nature of kix.
Top
#149280 - 2005-10-06 02:21 AM Re: KiXgolf: Fragmentation - Public Coding
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I don't golf. I just lurk about.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149281 - 2005-10-06 02:27 AM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
With a few modifications, like stealing Lonks use of a (instead of " ") as a separator, which was very smooth, here's an updated version of Allens's code with a score 233

Code:

function f($)
dim $h,$c,$o,$t,$a
$f=ubound($)
do
$h=$c+1
do
$a=$[$c]+$[$h]
if len($a)=2*len(join($,""))/($f+1)
$o=$o + a +$a+ a+ $[$h]+$[$c]
endif
$h=$h+1
until $h>$f
$c=$c+1
until $c=$f
for each $ in split($o,a)
$h=ubound(split($o,$))
if $h>$t
$t=$h
$f=$
;endif
;next
endfunction


Top
#149282 - 2005-10-06 02:36 AM Re: KiXgolf: Fragmentation - Public Coding
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I kept thinking I needed to keep track of occurances of a good result, and if their were duplicates in the array, like Eric did. But then I realized even if there was a duplicate, it would create a good and bad result, and there should always be more good results than bad, so long as the length is right. Like I said a few days ago... it works... but not exactly the right way.

Edited by Allen (2005-10-06 02:40 AM)

Top
#149283 - 2005-10-06 02:46 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I'm glad I took the rnd() route.
it seems that I would have had to use my brains with the brute force method.
_________________________
!

download KiXnet

Top
Page 1 of 5 12345>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 718 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.152 seconds in which 0.081 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org