Page 4 of 5 <12345>
Topic Options
#149324 - 2005-10-08 02:09 AM Re: KiXgolf: Fragmentation - Public Coding
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Here is a version of Pat's code chopped down a little...

Code:

KiXtart Engine
KiXtart Version = 4.50
KiXGolf Script = kixgolf_fragmentation.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed = 3192 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXGolf Score
Tournament = Fragmentation
Processing Start = 2005/10/07 19:47:30.273
Processing End = 2005/10/07 19:47:30.820
Duration = 0000/00/00 00:00:00.547
# Tests Run = 180
# Tests Passed = 180
# Tests Failed = 0
Result = passed
KiXGolf Score = 292

Thank you for participating in KiXtart Golf!



Code:

Function F($z)
Dim $m,$l,$i,$j,$,$s,$a,$g,$k,$v
$m=ubound($z)
$l=2*len(join($z,''))/($m+1)
for $i=0 to $m
for $j=0 to $m
$=$z[$i]+$z[$j]
if len($) = $l
$s=$s+#+$
$a=split(substr($s,2),#)
Dim $u
for $k=0 to ubound($a)
if ascan($a,$,$k,1) > -1
$u=1+$u
endif
next
if $v <= $u
$v=$u
for $k=0 to $m
$g=instr($,$z[$k])
next
if $g
$f=$
EndFunction


Top
#149325 - 2005-10-08 03:12 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
YEHAA!
I quess this does qualify as being under 200!
Code:

KiXtart Engine
KiXtart Version = 4.50 (WKIX32.EXE)
KiXforms Version = 2.46.29.0 / 3.1.17.0
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/08 03:48:36.088
Processing End = 2005/10/08 03:50:08.561
Duration = 0000/00/00 00:01:32.473
Used Processor Time = 00:01:26.664
# Tests Run = 181
# Tests Passed = 181
# Tests Failed = 0
Result = passed
KiXGolf Score = 188

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


Code:
Function f($u)
dim $i,$j,$c,$x,$
$j=ubound($u)
while $c<$j
$f='' $c=0 $x=$u
for $=1 to 0^join($u,'')
$f=$f+rnd(1)
$=$+$j/2
next
for $=0 to $j
for $i=0 to $j
if $i<>$ & $f=$x[$]+$x[$i]
$c=$c+2
$x[$i]=0
$x[$]=0
Endfunction

_________________________
!

download KiXnet

Top
#149326 - 2005-10-08 08:13 PM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Brilliant!!!

But since some of the tests contain values of 0, this might be 'safer'

Code:

Function f($u)
dim $i,$j,$c,$x,$
$j=ubound($u)
while $c<$j
$f='' $c=0 $x=$u
for $=1 to 0^join($u,'')
$f=$f+rnd(1)
$=$+$j/2
next
for $=0 to $j
for $i=0 to $j
if $i<>$ & $f=$x[$]+$x[$i]
$c=$c+2
$x[$i]=2
$x[$]=2
Endfunction


Top
#149327 - 2005-10-08 08:18 PM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
ideally, yes.
but I haven't found a case where the non-safe code fails, so...
_________________________
!

download KiXnet

Top
#149328 - 2005-10-08 11:21 PM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
been thinking it...
not sure it can fail at all.
basically, if the result should be "10" or "11", it could be fooled.
anyways, haven't tried but if you will, then we know
_________________________
!

download KiXnet

Top
#149329 - 2005-10-09 02:25 AM Re: KiXgolf: Fragmentation - Public Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yes, each test has only one valid solution. And changing the order of the file fragments should not break code, either. Regarding Test 54:
'0,00,10,1' can have only '100' as a valid solution. If you get '000' then the other fragemnt would be '101' or '110' which cannot be as all files were identical, now you got two non-identical files. I'll rotate a couple of tests, change the order of fragments. The winning code has to pass this.
_________________________
There are two types of vessels, submarines and targets.

Top
#149330 - 2005-10-09 11:14 PM Re: KiXgolf: Fragmentation - Public Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I have added five more tests. A download is available at http://s91376351.onlinehome.us/kixtart/kixgolf_fragmentation.zip

This will be the official test package. Any code that runs through this test package will get valid KiXgolf scores. Modifications to the test package will not be allowed. I will pass the final posted code from all participants through this set.
_________________________
There are two types of vessels, submarines and targets.

Top
#149331 - 2005-10-09 11:47 PM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sh*t.
non-responsive test package back.
_________________________
!

download KiXnet

Top
#149332 - 2005-10-09 11:50 PM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, my code passed it, huh.
was so scared and couldn't find anything to cut.
Code:

KiXtart Engine
KiXtart Version = 4.51
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/10 00:24:31.666
Processing End = 2005/10/10 00:25:51.911
Duration = 0000/00/00 00:01:20.245
# Tests Run = 185
# Tests Passed = 185
# Tests Failed = 0
Result = passed
KiXGolf Score = 188

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

_________________________
!

download KiXnet

Top
#149333 - 2005-10-10 12:31 AM Re: KiXgolf: Fragmentation - Public Coding
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Well here is my base (with modifications) working with all tests:

Code:
 
function f($)
dim $h,$c,$o,$t,$z
$f=ubound($)
for $c=0 to $f
for $h=$c+1 to $f
$t = a+$[$c]+$[$h]
$z = a+$[$h]+$[$c]
if len($t)=2*len(join($))/($f+1)
$o=$o+$t
if $t<>$z
$o=$o+$z
endif
endif
next
next
for each $ in split($o,a)
$h=ubound(split($o,$))
if $h>$t
$t=$h
$f=$
endfunction



Code:
 
KiXtart Engine
KiXtart Version = 4.51
KiXGolf Script = kixgolf_fragmentation.KIX

Computer
OS = Windows XP Professional
CPU = AMD Athlon(tm) 64 Processor 3200+
Speed = 2002 MHz
Memory = 510 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXGolf Score
Tournament = Fragmentation
Processing Start = 2005/10/09 18:08:36.484
Processing End = 2005/10/09 18:08:36.718
Duration = 0000/00/00 00:00:00.234
# Tests Run = 185
# Tests Passed = 185
# Tests Failed = 0
Result = passed
KiXGolf Score = 241

Thank you for participating in KiXtart Golf!



Edited by Allen (2005-10-10 12:38 AM)

Top
#149334 - 2005-10-10 01:34 AM Re: KiXgolf: Fragmentation - Public Coding
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Have been studying the 188 code for a while, but can't figure out the logic.

Is there anyone out there to make things clear?
_________________________
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
#149335 - 2005-10-10 02:14 AM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

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

Public coding ends Sunday, October 9, 2005, 6pm EST




dang, it's over.

now just waiting jens to announce the winners.
_________________________
!

download KiXnet

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
patrick, it goes something like:


while not all files matched, loop (the outer while-loop)
randomly pick 0's and 1's to form a string of those elements having the length of the file (the first for-to-next loop)
scan for all possible mixes of the pieces (the 2 inner for loops) and when it matches the randomly selected string (the if), increment the match count. also remove the pieces from the match array so the same pieces won't be accepted multiple times

and that's it.

I think.
_________________________
!

download KiXnet

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
as a side note, your code I didn't even try to understand and I think I never really understood Maciep's code totally.
guess it's enough for me that I know it's working
_________________________
!

download KiXnet

Top
#149338 - 2005-10-10 09:28 AM Re: KiXgolf: Fragmentation - Public Coding
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Jooel,

thanks for the info.

For those interested, here's my logic:

- Get length of the files by calculating the total length of the pieces, times 2, divided by the number of the pieces
- Determine the possible files constructed of the pieces (the 2 outer for's)
- The possible should have the same length as the original file (the length check)
- put all possibles in a 'solution' string
- count the number of times this possible is present in the total solution string
- check if all pieces could be found in the possible

the possible which is most frequent and for which the last check is true, is the right one.

Code:

Function F($)

Dim $m,$i,$j,$g,$k,$l,$u,$v,$a,$s,$p

;get the number of pieces and the length of a file
$m=ubound($)
$l=2*len(join($,''))/($m+1)

;following two 'for' loops is to determine possible files
for $i=0 to $m
for $j=0 to $m

;possible file contructed out of 2 pieces
$p=$[$i]+$[$j]

;if length possible=length file, continue
if len($p) = $l
;put the possible in a string containing all possibles
$s=$s+','+$p
$a=split(substr($s,2),',')

;check how many times possible is present in total string
$u=0
for $k=0 to ubound($a)
if ascan($a,$p,$k,1) >=0
$u=1+$u
endif
next

;if number of this possible >= previous max possible
;check if all pieces could be created from this possible
if $v <= $u
$v=$u
$g=1
;here the check is preformed
for $k=0 to $m
if not instr($p,$[$k])
$g=0
endif
next
;if pieces could be created, this possible is valid
if $g
$f=$p
endif
endif
endif
next
next

EndFunction



Jens,

I know it's too late but what if the input isn't all 0's and 1's?
My code even works () with an input of:

[Test0]
In=MightyR1, Rulez,MightyR1 ,Rulez,Migh,tyR1 Rulez
Out=MightyR1 Rulez

[Test1]
In=1,234567890,12,34567890,0,123456789
Out=1234567890
_________________________
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
#149339 - 2005-10-10 04:17 PM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
The original code i posted (with all of the arrays) will also work independent on what the test cases are.

Basically, my original code just checks all of different file combinations and keeps track of which pieces were used to create the combinations. And i made sure any file peice would only be used once for a certain combination.

Since there's only once solution possible, i just keep going until I find a combination that used all of the different pieces. That's why that original solution didn't care what the size of the file is - it doesn't really matter.

Top
#149340 - 2005-10-11 03:04 PM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ping pong.

jens?
_________________________
!

download KiXnet

Top
#149341 - 2005-10-12 06:41 AM Re: KiXgolf: Fragmentation - Public Coding
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Here are the results from both the privateand public coding phase. All submitted code was verified via the 185-test suite.

Private coding:
Jooel wins with a score of 229
Maciep has a score of 225 but fails 8 tests, so no cigar
Allen has a score of 255 and fails one test

Public coding:
Jooel wins the public coding as well with a score of 188
Macipe has submitted a virtually identical code (also 188) that is only modified in two places, however Jooel submitted first.
Next comes Allen with 241, followed by Chris S. with 292 and finally MightyR1 with 337.

Hope you all enjoyed our chemist.

I have not yet set dates for the next round. I do have a challenge but will need some more time to get the package ready and the test cases set up. It will be a two-week challenge from Friday to the following Sunday due to a little more complexity. I'm looking at mid-/late-November for the start. The topic of the next challenge has something to do with Kevin Bacon

BTW, there will be a year-end final ranking of all participants. And even participating will get you points.
_________________________
There are two types of vessels, submarines and targets.

Top
#149342 - 2005-10-12 02:04 PM Re: KiXgolf: Fragmentation - Public Coding
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
right judging.
wrong background info though...

maciep's code of 225 didn't make it to the private round.
also the public round follow up sounds little odd...

not bitter or anything... just anal as usual
_________________________
!

download KiXnet

Top
#149343 - 2005-10-12 04:17 PM Re: KiXgolf: Fragmentation - Public Coding
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
was wondering when my 225 code failed

Congrats to all the golfers!

Top
Page 4 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 686 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.076 seconds in which 0.027 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