Re: KiXgolf: Mayan Number Converter - Public Phase
This is the submission from Richard Mallesch (it_took_my_meds), which I am posting on his behalf: Code:
Function m($a)
$l=0,5,2,1,0 $v="|",":",".","-" $n = 1 If AScan($v,Left($a,1))=-1 Do $ = $a Mod ($n*20) $a = $a - $ $ = $ / $n $n = $n * 20 If $ For $q = 1 to 3 While $ / $l[$q] $m=$v[$q-1]+$m $=$-$l[$q] Loop Next Else $m="-"+$m EndIf $m=" "+$m Until $a=0 $m=Trim($m) Else $a = " "+$a While $a $c=Right($a,1) $=IIf($c=" ",-$,$+$l[AScan($v,$c)+1]) $a=Left($a,~) If $<0 Or $c="-" $m = $m - $n * $ $n = $n * 20 $=0 ;EndIf ;Next ;EndIf
EndFunction
Note: The code does not pass the validation as the variables inside the UDF are not declared despite "$iRC=SETOPTION('Explicit','on')" defined in kixgolf_mnc.kix
[edit] in the make I had a helper udf for power of 20, as well as a programmatic building of the mayan string; Something like this: $m = $m + left('.',( $} - $}/5) mod 2 ) + left('::',( $}-5*($}/5))/2) + left('|||',$}/5) + ' ' (where $} = $/${ , and ${ = p(6-$e) in a for 0 to 6) which was of course too long. That said, have a very nice weekend gentlemen, see you on monday [/edit]
Re: KiXgolf: Mayan Number Converter - Public Phase
A little comment on the challenge. The Mayan Number Converter basically consists of two transformations. Transformation #1 is the conversion of the Mayan symbols into a decimal number representation. Transformation #2 is a BASE20/BASE10 conversion between the Mayan vigesimal and the decimal numeral system.
Re: KiXgolf: Mayan Number Converter - Public Phase
Here is my 448, the additional UDF 'x($)'is the power calculator and both UDF's were placed between ;!,... ;! so that it was included in the count calc:
Code:
Function m($i) Dim $a,$b,$c,$,$p
If VarType($i)=8 $i=Split($i) For $c = UBound($i) to 0 Step-1 $=0 For $b = 1 to Len($i[$c]) $a=SubStr($i[$c],$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m+$*x($p) $p=$p+1 Next Else $p=1 Do $b=$i-$i/x($p)*x($p) $=$b/x($p-1) If $=0 $m="-"+$m Else For $c=1 to $/5 $m="|"+$m $=$-5 Next For $c=1 to $/2 $m=":"+$m $=$-2 Next If $=1 $m="."+$m $=$-1 EndIf EndIf $i=$i-$b $p=$p+1 If $i>0 $m=" "+$m EndIf Until $i=0 EndFunction
Function x($) Dim $y $x=1 For $y = 1 to $ $x=$x*20 EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
My god Eric - our code is almost identical:
My 213 is:
Code:
Function m($)
dim $a,$b,$c
for $b = 1 to 15 $c = split("- . : .: :: | " + $a) $a = $a + $c[$b] + "| " next
if $+0=$ $m = $c[$ mod 20] if $/20 $m = m($/20) + " " + $m endif else $ = split($) $b = 1 for $a = -ubound($) to 0 $m = $m + $b * ascan($c,$[-$a]) $b = $b * 20 ;next ;endif
EndFunction
This is my new public coding submission for a score of 185
Code:
Function m($)
dim $a,$b,$c
for $b = 1 to 15 $c = split("- . : .: :: | " + $a) $a = $a + $c[$b] + "| " next
if $+0=$ $m = $c[$ mod 20] if $/20 $m = m($/20) + " " + $m endif else for each $ in split($) $m = $m * 20 + ascan($c,$) ;next ;endif
EndFunction
By the way - I am officially protesting Jooels submission of 182. Jens - your going to have to verify it - none of us have time to do it - and if he does win - I figure the public golfing of it would take - like - 100 years !
Re: KiXgolf: Mayan Number Converter - Public Phase
285... Code:
; begin Mayan Number Converter ; ;! Function m($) dim $a,$b,$c,$p if $=$+0 do $b = $ mod 20 $=($-$b)/20
if $b $a=5,2,1 for each $p in $a while $b/$p>0 $m=substr(".:zz|",$p,1)+$m $b=$b-$p loop next else $m="-"+$m endif $m=" "+$m until $=0 $m=ltrim($m) else $c=1 for $a=len($) to 1 step -1 $b=substr($,$a,1)
if $b=" " $c=$c*20 endif $m=$c*instr(".:zz|",$b)+$m
Re: KiXgolf: Mayan Number Converter - Public Phase
This latest challenge was probably more interesting and fun that most of those we've had recently as it lends itself to many different paths to the solution.
I've discovered a few new techniques and tricks that surprised me, world weary old cynic that I am.
Anyhoo, here it is. Not the shortest, but a thing of chiaroscuric beauty none-the-less (in the authors humble opinion )
Code:
; begin Mayan Number Converter ; ;! Function m($n) Dim $,$c If $n=Val($n) Do $=$n mod 20 $n=$n/20 Do $c=($>4)*3+IIf($>1,2,$) $=$-$c $m=SubStr("-.:xx|",$c+1,1)+$m Until $=0 $m=" "+$m Until $n=0 Else For Each $ in Split($n) $m=$m*20 While $ $m=$m+InStr(".:xx|",Left($,1)) $=SubStr($,2) Loop Next EndIf $m=Trim($m) EndFunction ;! ;! ; end Mayan Number Converter ; vim600:filetype=kix ai sw=4 ts=4
Re: KiXgolf: Mayan Number Converter - Public Phase
I'll have to go offline for most of th day. Please continue posting your entreis for the private phase so that I can validate them. And, FYI, I have my own tests, additional combinations that I'm running. Plus, code has to finish within the timeframe for the tournament.
Re: KiXgolf: Mayan Number Converter - Public Phase
Here's some golf tips for the public round - assuming your going to maybe start with the 185 code:
1) The best opportunity for removing strokes (imho) is here:
Code:
for $b = 1 to 15 $c = split("- . : .: :: | " + $a) $a = $a + $c[$b] + "| " next
If anyone can find a shorter way to build a mayan character table - it will be gold.
The other place is here:
Code:
if $+0=$
If anyone can find a shorter numeric check or b) find a similar or shorter way to test for STRING instead. If you can find a string check - then one should be able to flip the code blocks around - probably saving a single stroke on the commented-out nexts and endif's
One word of caution - this here:
Code:
$m = m($/20) + " " + $m
is a recursive call - so things like IIF() will not work. IIF expressions always get evalulated so using them can cause an endless recurse. Of course - thats just been my experience ;o)
Re: KiXgolf: Mayan Number Converter - Public Phase
More about that table ...
Code:
for $b = 1 to 15 $c = split("- . : .: :: | " + $a) $a = $a + $c[$b] + "| " next
If one is able to bring the number of $vars down from 3 to 2 - and still keep the same number of strokes - then one should be able to remove the DIM of the $var - and save like three strokes !
I've been staring at this table for days - with zero luck.
For reference - here is the absolute max way of defining the table:
Re: KiXgolf: Mayan Number Converter - Public Phase
Why does the following work? Maybe I stayed up too late night and just can't think straight, but why isn't "$" redefined and fail on the next iteration.
Code:
for each $ in split($)
Code:
$="1 2 3 4 5" ? Vartypename($) ? $ for each $ in split($) ? $ ? Vartypename($) next ? Vartypename($) ? "$$="+$
The original value of "$" is set to Empty after the loop.
Re: KiXgolf: Mayan Number Converter - Public Phase
idk, I learned that just a few days ago - when we all golfed-down that sample script in the post where Jen's announced this tournament. My guess is the "IN" variable only gets evaluated once ? I suppose once the enum starts - its not valid to change it on the fly - maybe its a oversight on Ruuds part.
Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn, very nice with that 185 code. That $m = $m * 20 + ascan($c,$) would have never crossed my mind. And i like the way you built out the mayan numbers - i knew there was room for improvement in the way i did it.
By the way, i was trying to get a half recursive solution going last night, but was too sick of staring at the code
Re: KiXgolf: Mayan Number Converter - Public Phase
I think there is still room for improvment in that mayan table - somehow getting rid of that 3rd $var - but I can't wrap my mind around it. Or shrinking that mayan string somehow and adding some math-magic - idk . Or something totally new and radical more like.
In terms of the recursive - I did try it "both ways" (to and from at same time) ... and it does work - but I found the overhead on the string side to be too big - but then, that was a few days ago ... one might revisit a double-recurse.
Re: KiXgolf: Mayan Number Converter - Public Phase
Because of the wicked thunderstorms in the northeast US, I was alternately without power or cable/internet for several hours and was unable to post my lowest score of 326. I've included those enhancements as comments in the code, marked by "LATE! -# strokes". Damn weather made us postpone my daughter's 12th birthday party today!
Somebody asked for commented code so they could learn about the logic, so, here's my commented 337-stroke version: Code:
; begin Mayan Number Converter ; ;! Function m($) ; - 57 stroke overhead
Dim $_,$C,$D
If VarType($)=8 ; is it a mayan string?
; Mayan to Decimal - 96 strokes $D=1 ; initial multiplier value
; work from LSD to MSD For $_=Len($) to 1 Step -1
; get Mayan char value based on string position ; InString will report 1, 2, 5, or 6 (delimiter) $C=InStr('.:xx| ',SubStr($,$_,1))
If $C=6 ; Delimiter? move to next multiplier power of 20 $D=$D*20 Else ; is a vaid digit value - multipliy by current multiplier value ; and add to running total $m=$m+$C*$D ; process value EndIf
Next ; next string character
Else ; or a Decimal Value?
; Decimal to Mayan - 184 strokes $D=64000000 ; highest divisor value for 7 digits
While $D>=1 ; loop while divisor is greater than 0 ;While $D ; LATE! -3 strokes ; divide by max value, result will be between 0 and 19 - a Mayan "Digit" $C=$/$D $=$ Mod $D
; If not zero, output the Mayan chars that make up this "digit" If $C $m=$m+$_+SubStr('.',1,$C Mod 5 Mod 2)+SubStr('::',1,$C Mod 5/2)+SubStr('|||',1,$C/5) $_=' ' ; inter-digit space after the first one Else ; if zero, output a zero only if other digits exist, eliminates leading "shells" If $m $m=$m+' -' EndIf EndIf
$D=$D/20 ; reduce the divisor by power of 20
Loop
; If no digits were generated, return only a null shell "digit" $m=IIf($m='','-',$m) ;$m=IIf($m,$m,'-') ; LATE! -3 strokes
Re: KiXgolf: Mayan Number Converter - Public Phase
Just using the table generator and the -ubound trick dropped my original function by 21 strokes...
Code:
;225 Function m($) dim $y,$r,$c for $c = 1 to 15 $y = split("- . : .: :: | " + $r) $r = $r + $y[$c] + "| " next if $+0=$ do $r=$ mod 20 $m=" "+$y[$r]+$m $=$/20 until $=0 $m=trim($m) else $c=split($) $r=1 for $=-ubound($c) to 0 $m=$m+ascan($y,$c[-$])*$r $r=$r*20 ; next ; endif EndFunction
Shawn... I've been staring at your 182... how are you trimming the Mayan number?
Re: KiXgolf: Mayan Number Converter - Public Phase
There is no need to trim ... this
if $/20
gives a hint that there are more characters to come ... and since the " " is only added if there are more chars. There is never that "trailing space" that needs to be trimmed.
Re: KiXgolf: Mayan Number Converter - Public Phase
Rogier, I liked your code so I just had to play with it, doing away with $a = $ mod 20 saved you 1 stroke, you now have 216.
Code:
Function m($) Dim $a If $+0=$ Do $m = IIf($ mod 20,Left('.',$ mod 5 mod 2)+Left('::',$ mod 5/2)+Left('|||',$ mod 20/5),'-')+' '+$m $ = $ / 20 Until $ = 0 Else $a = InStr('-.:__|', Left($,1)) $m = m(IIf($a, $m+$a-1, $m*20)) $ = Right($,~) EndFunction
Code:
Mayan Number Converter passed all 60 tests (100% correct)
KiXtart KiXtart Version = 4.52 KiXGolf Script = kixgolf_mnc.kix
Computer OS = Windows XP Professional CPU = Intel(R) Pentium(R) D CPU 2.80GHz Speed = 2793 MHz Memory = 2048 MB
Re: KiXgolf: Mayan Number Converter - Public Phase
After running all submitted codes through my own tester, here's the current results: Code:
Jooel --------- 182 1. Shawn --------- 185 (confirmed) 2. Shawn --------- 213 (confirmed) 3. DrillSergeant - 217 (confirmed) Jooel --------- 219 4. Maciep -------- 225 (confirmed) 5. Richard H ----- 252 (confirmed) 6. Allen --------- 256 (confirmed) 7. Howard bullock 285 (confirmed) 8. Glenn Barnas -- 337 (confirmed) It_took_my_meds 343 (does not pass validation due to not DIMming variables inside the UDF) 9. Jochen -------- 352 (confirmed) 10. Benny69-------- 448 (confirmed) 11. Krabourn ------ 651 (confirmed)
Please note that Jooel has not submitted either of his two solutions, therefore the KiXgolf scores are unconfirmed and thus not reflected in the ranking. As of right now, Shawn would actually be the winner of the private phase.
Re: KiXgolf: Mayan Number Converter - Public Phase
And here are the current standing of the public pase, not much has happened, though Shawn was able to improve his own code a bit. Benny69 moved up to 4th place due to his improvements to DrillSergeant's code. Sounds like the hunt is on to improve Shawn's code. Code:
Jooel --------- 182 1. Shawn --------- 182 (Shawn-185 was reduced by 3 strokes) 2. Shawn --------- 185 (confirmed) 3. Shawn --------- 213 (confirmed) 4. Benny69 ------- 216 (DrillSergeant-217 was reduced by 1 stroke) 5. DrillSergeant - 217 Jooel --------- 219 6. Maciep -------- 225 (confirmed) 7. Allen --------- 225 (Allen-256 was reduced by 21 strokes) 8. Richard H ----- 252 (confirmed) 9. Allen --------- 256 (confirmed) 10. Howard bullock 285 (confirmed) 11. Glenn Barnas -- 337 (confirmed) It_took_my_meds 343 (does not pass validation due to not DIMming variables inside the UDF) 12. Jochen -------- 352 (confirmed) 13. Benny69-------- 448 (confirmed) 14. Krabourn ------ 651 (confirmed)
Re: KiXgolf: Mayan Number Converter - Public Phase
Quote: Cappy, that $ = right($,~) thing ... had to actually run it to figure it out. Its a shorter form of $ = right($,-1). Seems like this:
$ = right("cappy",~)
would return "appy"
That is brilliant.
Yes, brilliant. I havn't run it, but still, after you pointed it out, how could one possibly figure that out without having the kixtart source code? Rogier, what the green heck did you do to find that one, asked Ruud??
Well, my deep respect to all of you. I started thinking of reducing the mayan string array thing last week, but that was only wishful thinking for me
Re: KiXgolf: Mayan Number Converter - Public Phase
sorry boys. the bachelor party went on a bit longer than they normally do. I'm not fit to code anything yet but let me find the codes for you...
the 182 code: Code:
Function m($i) dim $e, $, $n if $i=0+$i do $ = $i mod 20 do $n = 3*($>4) + ($>1) + ($>) $e = substr('-.:__|',1+$n,1) + $e $ = $ - $n until $=0 $m = $e + $m $e = " " $i = $i/20 until $i=0 else $m=-1 do $m=$m+1 until $i=m($m) EndFunction
and the 219: Code:
Function m($) dim $e, $i, $n if $=0+$ do $i = $ mod 20 $m = split(" . : .: :: -")[iif($i=0,5,$i mod 5)] + left('|||',$i/5) + $e + $m $e = ' ' $ = $/20 until $=0 else $i=split($) $=1 for $n=-ubound($i) to 0 for $e=0 to 19 if $i[-$n]=m($e) $m = $m + $ * $e $ = $ * 20 EndFunction
and shawn, no matter how much you protest, the rules are clear. as long as the code executes in the alloted time, it is fine. this is not the first golf round when these type of codes are used. in fact, way back on one golf round the tests were altered by individuals so these type of codes didn't suffer so much time penalty.
Re: KiXgolf: Mayan Number Converter - Public Phase
hmmmm, are we were allowed to change the names of the parameters ?
Anyway - heres the thing Jooel - by submitting this brute-force kinda code, your basically spoiling the spirit of these games. Now going-forward - in order for anyone to compete with you (me included) - we're going to have to start writing more of this silly stuff.
Do the Perl golf tournaments have this same problem ?
Re: KiXgolf: Mayan Number Converter - Public Phase
I'm posting this 173 on behalf of Rogier (DrillSergeant) ...
Code:
;! Function m($)
dim $a
if $=0+$ do $a = $ mod 20 $m = trim(iif($a,left('.',$ mod 5 mod 2)+left('::',$ mod 5/2)+left('|||',$a/5),'-')+' '+$m) $ = $ / 20 until $ = 0 else $m=-1 do $m=$m+1 until $=m($m) EndFunction ;!
Re: KiXgolf: Mayan Number Converter - Public Phase
This is 167
This one I am submitting on behalf of me, Rogier and Benny ... especially Benny because he found the reduction ...
Code:
Function m($)
if $=0+$ do ;$a = $ mod 20 $m = trim(iif($ mod 20,left('.',$ mod 5 mod 2)+left('::',$ mod 5/2)+left('|||',$ mod 20/5),'-')+' '+$m) $ = $ / 20 until $ = 0 else $m=-1 do $m=$m+1 until $=m($m) EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
I just want to recap the last three script submissions and credits - Jens will need this info when he validates all three scripts seperately to ensure standings ...
Re: KiXgolf: Mayan Number Converter - Public Phase
not true. the function is scored in it's whole because you can change it as much as you like as long as it works. and my 176 works and does run fine and fast.
there is no rule about changing the variable names but as long as there has been kixgolf, as many times the names have been changed by the winning code.
so why would we start changing the rules and well established guidelines just because shawn says so?
Re: KiXgolf: Mayan Number Converter - Public Phase
Well, I have no intention of running that shit code through all test cases. So I officially withdraw it ... if anyone wants to take it - the lower score is all yours.
So I guess with that said, your back in the lead Jooel.
Re: KiXgolf: Mayan Number Converter - Public Phase
Regarding the brute-force approach, this rule pretty much covers it:
Quote:
The UDF is expected to finish in a reasonable time, e.g. if it gets started when the challenge opens, it's expected to be finished by the time the challenge closes even on a somewhat slow computer. The UDF has to be valid during the period that the challenge runs.
plus I have the ultimate say:
Quote:
6) In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.
We do have a precedence where we allowed a brute-force approach in the CD Sorter challenge.
However, I am currently running Jooel's initial solution. On a rather fast computer (AMD Athlon 64 X2 3800+), the brute-force approach requires on average 2 seconds to rotate through 10.000 numbers. This highest number I have in my private test cases is ::||| ::||| ::||| ::||| ::||| ::||| ::|||=1279999999. This number alone will require three days to compute. Thus, I believe that this violates the "reasonable time" rule as throwing in a single additional test, e.g. 1279999998 case will make the brute-force approach run well after the conclusion of the public round.
Therefore the brute-force approaches, while a creative demonstration, will not qualify for valid KiXgolf scores under the "reasonable time" rule.
Regarding changing the parameters inside the FUNCTION line, there is no rule covering this. I am tending to continue allowiing this as there might be a tournament where one want to add an addtional OPTIONAL parameter into the function call in order to implement some kind of recrsive solution. There is a precedence where I changed the names of the parameters inside the FUNCTION mid-tournament in order to not penalize a recursive solution, thus it's kind-of a precedent.
After the conclusion of this tournament, I will post the updated rules for discussion.
Re: KiXgolf: Mayan Number Converter - Public Phase
Quote: 6) In case of questions about a particular way to count the KiXtart Golf Challenge organizer has the last call.
Well I guess that sums it up rather easy.
Okay, given a bit of a history lesson I'll agree with you on this one Jooel. However being that this was the first one where I even really attempted it and the Function($) EndFunction was supplied I did not think that one could or should modify it. However since Jens sees fit to do so that's fine as well, but it should be clearly listed as a possible option in the rules for future games.
Re: KiXgolf: Mayan Number Converter - Public Phase
jens, so, you really think you wanna over run our rules in this round?
you first clearly state that it must finish in time and so it did. in fact, the private round was lot longer than the 3 days it took to run the code.
so, if you disqualify proper working code just because you feel like you have the power to do so, be my guest. but don't argue it has anything to do with judging or reason, it's purely personal.
Re: KiXgolf: Mayan Number Converter - Public Phase
I for one have learnt a lot from this competition and I take my hat off to all the people who kicked my ass. I would also like to thank Jens for putting on the competition; particularly as he doesn't even get to participate!
As for this discussion regarding brute force solutions, don't get too worked up about it guys as after all it's just a friendly competition to inspire ideas for coding. That being said, whilst a brute force solution may be shorter it is not something I would use in a normal script and it doesn't inspire me to use different constructs or approaches to algorithms. Shawn's code is both clever and elegant and gets my vote for the best solution.
Re: KiXgolf: Mayan Number Converter - Public Phase
Now, now, boys, play nice
First of all, I took benny's 216 and I got one stroke down with the Jooel-trick to define the space after the first mayan number and adding that for the rest. So I got a 215 now. Code:
; begin Mayan Number Converter ; ;! Function m($) dim $a If $+0=$ Do $m = iif($ mod 20, left('.',$ mod 5 mod 2)+ left('::',$ mod 5/2)+left('|||',$ mod 20/5),'-')+$a+$m $a = ' ' $ = $ / 20 Until $ = 0 Else While $ $a = instr('-.:__|', left($,1)) $m = iif($a, $m+$a-1, $m*20) $ = right($,~) EndFunction ;! ;! ; end Mayan Number Converter
Code:
Mayan Number Converter passed all 60 tests (100% correct)
I think I took the ~ trick from a former golf course I've read, or else I've been playing around with all binary operators to see how they would react to different numbers.
The double mod is a result of golfing down the original code. slashing out variables where-ever I could. If I have time I'll rebuilt the code back to the basics so that it's easier to understand.
Brute force? For me, that's a bit icky. Besides, it's a coding contest...
Change variables? I've looked into that too, but it wouldn't have improved my score, or else I would have done it too.
Recursive function? Damn... should have thought of that too!
Jens, looking at the setup and preparation for this, I'm guessing you've spend a lot of work on it.
If there wasn't a perfect test-environment and everything, I prolly wouldn't have even teed off. So in my book, you own the sandbox, and you can change the rules however you seem fit. Thank you for this nice round, and I'm very much looking forward to the next one.
Re: KiXgolf: Mayan Number Converter - Public Phase
Not to screw up the party but this rule:
Quote:
3) Code can be constructed any way you like, as long as it is syntactically correct with KiXtart.
Clearly says that it should be correct syntax. Commenting out the endif’s and the next so that they will not be executed and as far as I know do not get counted by the scoring engine is not correct kix syntax imho. Maybe I'm wrong about the scoring engine but it still is not correct kixtart syntax.
Re: KiXgolf: Mayan Number Converter - Public Phase
There's been no rules broken so far. Jens gave his explaination sighting the rules. You got your change-parameter rule verified. I withdrew my crappy scripts because of the rules. So what other rules were broken ?
By the way - my take on correct syntax is - as long as the interpreter doesn't complain about it - its correct syntax.
Re: KiXgolf: Mayan Number Converter - Public Phase
Listen man, I apologize for being an asshole. Your one of the best darn scripters out there - it bugs me when you pull these cheap tricks. You got more skills than that man. Sorry buddy.
Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn summed it up regarding correct syntax:
Quote:
By the way - my take on correct syntax is - as long as the interpreter doesn't complain about it - its correct syntax.
The interpreter is not complaining, so why should I
It's not my fault that KiXtart doesn't check for closing ENDIFs. But if everybody wishes I can submit this as a) a bug report to Ruud to be fixed in the next version, or b) an incorrect description in the KiXtart Manual as ENDIFs are apparently optional. Maybe the corresponding entry should be written as IF...[ELSE]...[ENDIF] to indicate otional ELSE/ENDIF.
Regarding the brute-force methods, I have Jooels code running on my work-laptop since this morning and that thing is not making much progress. I consider this common business laptop model (IBM T40) as representative of a "somewhat slower" computer.
And just to make it clear, I have not disallowed brute-force methods outright, maybe one of the next KiXgolf challenges might even use one. What the rule does not allow is excessive run-times to solve the challenge. Three days on a rather fast computer and then extrapolated most likely six days for the complete set of tests is in my mind on the rather excessive side.
An updated ranking of the public challenge will follow tomorrow.
Re: KiXgolf: Mayan Number Converter - Public Phase
jens, you consider 2,8GHz celeron a fast computer?
and, if you run the code with the test cases you gave us and not your hidden private tests, it will surely finish in time.
now, if the rule does not allow excessive run-times, you should change the rule to say that. as now the rule says "as long as the code finishes inside the phase's alloted time, it's ok" and again, 3 days is lot less excessive than what the rule says is allowed.
Re: KiXgolf: Mayan Number Converter - Public Phase
Agreed the run time rule is not very clearly defined.
I'd suggest setting an explicit run time and hardware - say a maximum of three hours on, ooh I dunno, a 2.8Ghz Celeron
If you only propose challenges which would reasonably be expected to complete in seconds or minutes a restricted time limit is not going to be onerous.
Sure, it will mean that some methods cannot be used, but that's part of the challenge - if you try a tricky shot off the fairway over the trees and you land in the lake then you have to accept a dropped shot and try another way around.
Re: KiXgolf: Mayan Number Converter - Public Phase
I applaud Jen's patience here. I mean, if everyone wrote these kinds of scripts - he would need weeks and prolly a server farm to validate these kinds of answers. And I think hes being pretty generous by using a 1.5ghz machine - the official Perl rules site a 100mhz P II as a "somewhat slow computer".
Having said that - assuming Jooels script finishes in a reasonable time or not - and with Jen's OK - I have no problem sharing the private round 1st place with Jooel - he deserves something.
Re: KiXgolf: Mayan Number Converter - Public Phase
According to the rules - wouldn't all long-running scripts need to be independently verified on the target "slow-computer" ? Would that imply that folks with extremely fast machines would have an advantage over others ?
Re: KiXgolf: Mayan Number Converter - Public Phase
no, you boys got it wrong. the script uses processing time. it has nothing to do with the time spent by other processes.
where was that kixFlop() udf of mine...
anyways, calculating approximate speed of a computer and then comparing the time spend by the script to run. when using huge number of "flops" to add single stroke penalty, it doesn't matter if the speed tester is 110% accurate or not.
it should add no penalty to your score. but if you add sleep 1 or something alike into your script, it should start penalizing. currently the "weight" is set to 20 but it can be adjusted as much as one wants... well, we/jens would want.
Re: KiXgolf: Mayan Number Converter - Public Phase
oh, and if you do try it, you will most likely notice the "progress" numbering I added there. I asked jens to do that a long time ago but as he hasn't, I tend to add it on my own in every scorer. if the script runs longer than a second, one needs to know how the progress goes. oh, and also added the error reporting lines. don't show up on correct code but with failing code it prints out what went wrong.
Re: KiXgolf: Mayan Number Converter - Public Phase
hmm... speedstep seems to kick the processortime calculus out the door
but on the other hand... adding lot larger value to the weight evens the odds of that affecting the results. changed also the timepenalty udf a little. now the calculation happens after the code is done, so changing cpu speed should not have that much of an effect. Code:
function TimePenalty(optional $in, $weight) dim $,$h if vartype($in) for $h=0 to 100000 next $=ProcessorTime() for each $h in split("1 2 3") $h = "a" + (1 - (0.147 * $h)/27) next $TimePenalty=(ProcessorTime(,,$in)/ProcessorTime(,,$))/(0+$weight) else $TimePenalty = ProcessorTime() endif endfunction
Re: KiXgolf: Mayan Number Converter - Public Phase
don't remember, but I do remember that we had a golf round back when in which my code took about 2 days to complete.
anyways, updated the timepenalty udf (and the download zip): Code:
function TimePenalty(optional $in, $weight) dim $,$h,$x if not vartype($in) $=ProcessorTime() do $x=$x+1 until 10000000<ProcessorTime(,,$) $=ProcessorTime() for each $h in split("1 2 3") for $x=0 to 70203 next $h = "a" + (1 - (0.147 * $h)/27) next $TimePenalty = ProcessorTime(),ProcessorTime(,,$) else $TimePenalty=(ProcessorTime(,,$in[0])/$in[1])/(0+$weight) endif endfunction
Re: KiXgolf: Mayan Number Converter - Public Phase
lol - NICE !
I was just going to post this variation on Rogier's theme - a 207 - got to see this other one though cripes ...
Code:
Function m($)
dim $a,$t[19]
if $=$+0 $m = iif($ mod 20,split(' . : .: ::')[$ mod 5],'-') + left('|||',$ mod 20/5) $=$/20 if $ $m = m($) + ' ' + $m endif else for $a = 0 to 19 $t[$a] = m($a) next for each $a in split($) $m = $m * 20 + ascan($t,$a) ; next ;endif
Re: KiXgolf: Mayan Number Converter - Public Phase
185 Code:
Function m($)
if $<$+0 for each $ in split($) dim $a while m($a)<>$ $a = $a + 1 loop $m = $m * 20 + $a next else $m = iif($ mod 20,split(' . : .: ::')[$ mod 5],'-') + left('|||',$ mod 20/5) $=$/20 if $ $m = m($) + ' ' + $m EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
Rogier and I can play this game, here is Jooel code 149 :
Code:
Function m($) If $<$+0 $m=-1 Do $m=$m+1 Until $=m($m) Else $m = IIf($ mod 20,Split(' . : .: ::')[$ mod 5],'-') + Left('|||',$ mod 20/5) $=$/20 If $ $m = m($) + ' ' + $m EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase - 170
How about this proposal, we'll create two rankings, one for the algorithmic approach and a second one for the brute-force approach? From a scoring perspecitve, I am considering to award points to the first five people on either list, with brute-force solutions being penalized by a one point reduction. Scoring would then be: Code:
Re: KiXgolf: Mayan Number Converter - Public Phase - 170
For me it sounds like no big change. Dunno how good the common knowledge about brute force coding is here, but I'll give for the time being give my 'vote' to this proposal
Re: KiXgolf: Mayan Number Converter - Public Phase - 170
I dont like the idea of keeping two rankings - one for algorithmic and one for brute-force. Reason - no matter what the challenge is - even if the brute-force approach takes more code - someone will submit one just to get the easy points.
Having said that, I dont have a good answer for this brute-force versus algorithmic thing either.
Re: KiXgolf: Mayan Number Converter - Public Phase - 170
I don’t think that any of us would use any script that takes days to run, most of us get frustrated with almost any program that does not react within seconds. I think that brute force has its place and if it can be used in practical situations it should be allowed, otherwise there should be penalties for the score that start adding up quickly after 20-30 seconds (the point of frustration).
Re: KiXgolf: Mayan Number Converter - Public Phase
Exactly - thats why we have to be careful about the term brute-force. One can argue that the 170 code does a brute-force search for part of the answer (scan mayan table) - versus Rogiers code that is totally algorithmic. The Rogier 185 code uses a brute-force recursive teqhnique.
Re: KiXgolf: Mayan Number Converter - Public Phase
i think that the POF would be set for each tournament depending on what is trying to be accomplished, and as far as 'Brute Force' I see that as any code that in any way or form that counts 1 by 1 until the result is found. if it can be accomplished inside the POF it should be allowed, if it is outside the POF then penalties should be applied.
Re: KiXgolf: Mayan Number Converter - Public Phase
My 2 cents.
Well I can't speak for everyone as some will disagree, but I think we all participate in one form or another for the fun of it and not all this haggling and disagreement.
I'm sorry but I just can't see myself bogging down my computer for hours so that I can't really use it for anything else just to have the lowest score because there is no time limit and I really want to win at all costs.
I would suggest that the challenges be limited to challenges that normal optimized proper coding techniques can complete within 30 minutes on a P4 800Mhz 256MB system. Then any Golfing code must complete within 1 hour. If your code can not complete within 1 hour then you need to come up with some other type of code.
This would allow Jens or others to validate entries properly within a reasonable time frame. If you had 10 entries of code that took 3 days each to run it would take a month to validate the code which is just not reasonable.
So - my suggestion is any submitted Golf code must pass the scoring engine and complete within 1 hour period.
Re: KiXgolf: Mayan Number Converter - Public Phase
I agree with Doc. 1 hour seems like a reasonable amount of time for any golf challenge. That's probably the simplest solution for the 'brute-force' debate.
Re: KiXgolf: Mayan Number Converter - Public Phase
POF may not be the way to go, but I do think we all are in agreement that time boundaries need to be set. I think 1 hour is a bit too long, but it is not unreasonable. I do think that the 1 hour time frame should be limited to what I would call a slow machine, say a PIII 800mhz, so if the same code was run on a machine like mine 2.8ghz dual core it should have to take less than 1 hour.
Re: KiXgolf: Mayan Number Converter - Public Phase
Well perhaps we can get input from Jens and Jooel too.
Over all I would say the 1 hour is too much as well, but I didn't want to seem to be too restrictive in case Jens or whomever sets up a Golf challenge came up with something that legitimately takes maybe 10 minutes or more to run with proper coding techniques.
If everyone is in agreement then maybe set the maximum time to complete the challenge to 15 minutes.
The speed and type of the PC to validate the challenge should not be such a big issue either (imho) if it’s going to spoil the spirit of the game.
The code should complete within the 15 minutes on ANY commercially sold retail computer within the last 2 years that is not bogged down with spyware or is incapacitated in some other form or fashion that would negatively impact it’s normal performance.
A.) Must pass scoring engine tests B.) Must complete script execution within 15 minutes
I would also like to ask that TRIM be added to the scoring engine code to remove the tab/spaces in the CPU name.
Re: KiXgolf: Mayan Number Converter - Public Phase
I think the one hour time restriction would be feasible. I do not recall any KiXgolf tournament where the code ran for more than just a couple of minutes, Howard's CD Sorter and Jooels Mayan Numbers excluded. So, going forward, max runtime would be one hour.
Re: KiXgolf: Mayan Number Converter - Public Phase
Thanks Jens, I really have no intention to use the 149 code and would like to officially remove it from the competition, it was meant more as a joke, and as in the recent discussion it removes from the spirit of the game.
Re: KiXgolf: Mayan Number Converter - Public Phase
jens, I do remember that in some round I had to reduce the tests by removing the hardest ones in order to be able to run the validator inside couple hours.
anyway, the one hour limit is ok for me. but think there will be cases in the future that a code runs in 55 minutes on one computer and 1:05 on another and we will have this discussion again.
Re: KiXgolf: Mayan Number Converter - Public Phase
Quote: but think there will be cases in the future that a code runs in 55 minutes on one computer and 1:05 on another and we will have this discussion again.
You could do what you suggested in an earlier post - rather than using real time as a metric, use user cpu cycles. This should be pretty close on main processor lines for the types of challenges that we are undertaking.
You can't include system CPU cycles as these are too easily influenced by whatever else the PC is up to.
Now all you need to do is calculate a reasonable user CPU load for 15 minutes
Re: KiXgolf: Mayan Number Converter - Public Phase
SPIRIT guys, SPIRIT
5 or 15 minutes isn't going to hurt anyone. Main idea is that no one has time or inclination to validate anything that runs for hours and hours or even days.
Re: KiXgolf: Mayan Number Converter - Public Phase
After revisiting my original code I was able to golf it down to 380.
Code:
Function m($i) Dim $a,$b,$c,$d,$,$p
If $i=$i+0 $p=20 $a="|",":","." $d=5,2,1 Do $b=$i-$i/$p*$p $=$b/($p/20) If $=0 $m="-"+$m Else For $c = 0 to 2 While $/$d[$c] $m=$a[$c]+$m $=$-$d[$c] Loop Next EndIf $p=$p*20 $i=$i-$b If $i>0 $m=" "+$m EndIf Until $i=0 Else $p=1 $i=Split($i) For $c = UBound($i) to 0 Step-1 $=0 For $b = 1 to Len($i[$c]) $a=SubStr($i[$c],$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m+$*$p $p=$p*20 ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
4 more for 376:
Code:
Function m($i) Dim $a,$b,$c,$d,$,$p
If $i=$i+0 $p=20 $a="|",":","." $d=5,2,1 Do $b=$i mod $p $=$b/($p/20) If $=0 $m="-"+$m Else For $c = 0 to 2 While $/$d[$c] $m=$a[$c]+$m $=$-$d[$c] Loop Next EndIf $p=$p*20 $i=$i-$b If $i>0 $m=" "+$m EndIf Until $i=0 Else $p=1 $i=Split($i) For $c = UBound($i) to 0 Step-1 $=0 For $b = 1 to Len($i[$c]) $a=SubStr($i[$c],$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m+$*$p $p=$p*20 ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
Benny-353
Code:
Function m($i)
Dim $a,$b,$c,$d,$,$p
If $i=$i+0 $a="|",":","." $d=5,2,1 Do $b = $i mod 20 If $b=0 $m="-"+$m Else For $c = 0 to 2 While $b/$d[$c] $m=$a[$c]+$m $b=$b-$d[$c] Loop Next EndIf $i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else $p=1 $i=Split($i) For $c = UBound($i) to 0 Step-1 $=0 For $b = 1 to Len($i[$c]) $a=SubStr($i[$c],$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m+$*$p $p=$p*20 ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
but, just for the fun of it... 338 Code:
Function m($i)
Dim $a,$b,$c,$d,$
If $i=$i+0 $a="|",":","." $d=5,2,1 Do $ = $i mod 20 If $=0 $m="-"+$m EndIf For $c = 0 to 2 While $/$d[$c] $m=$a[$c]+$m $=$-$d[$c] Loop Next $i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else $d=1 $i=Split($i) For $c = -UBound($i) to 0 $=0 For $b = 1 to Len($i[-$c]) $a=SubStr($i[-$c],$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m+$d*$ $d=$d*20 EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
Benny-313
Code:
Function m($i)
Dim $a,$b,$c,$d,$
If $i=$i+0 $a="|",":","." $d=5,2,1 Do $b = $i mod 20 If $b=0 $m="-"+$m Else For $c = 0 to 2 While $b/$d[$c] $m=$a[$c]+$m $b=$b-$d[$c] Loop Next EndIf $i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else For Each $c in Split($i) $=0 For $b = 1 to Len($c) $a=SubStr($c,$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m*20+$ ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
309 Code:
Function m($i)
Dim $a,$b,$c,$d,$
If $i=$i+0 $a="|",":","." $d=5,2,1 Do $b = $i mod 20 If $b=0 $m="-"+$m Endif For $c = 0 to 2 While $b/$d[$c] $m=$a[$c]+$m $b=$b-$d[$c] Loop Next
$i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else For Each $c in Split($i) $=0 For $b = 1 to Len($c) $a=SubStr($c,$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m*20+$ ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
Benny-304
Code:
Function m($i)
Dim $a,$b,$c,$d,$
If $i=$i+0 $a="|",":","." $d=5,2,1 Do $ = $i mod 20 If $=0 $m="-"+$m Endif For $c = 0 to 2 While $/$d[$c] $m=$a[$c]+$m $=$-$d[$c] Loop Next
$i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else For Each $c in Split($i) $=0 For $b = 1 to Len($c) $a=SubStr($c,$b,1) $=$+($a=".") $=$+($a=":")*2 $=$+($a="|")*5 Next $m=$m*20+$ ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
293 Code:
Function m($i)
Dim $b,$c,$d,$
If $i=$i+0 $d=5,2,1 Do $ = $i mod 20 If $=0 $m="-"+$m Endif For $c = 0 to 2 While $/$d[$c] $m=split("| : .")[$c]+$m $=$-$d[$c] Loop Next
$i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else For Each $c in Split($i) $=0 while $c $b=left($c,1) $c=right($c,~) $=$+($b=".")+($b=":")*2+($b="|")*5 loop $m=$m*20+$ ;Next EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
k, it's back in. 295 Code:
Function m($i)
Dim $a,$b,$c,$
If $i=$i+0 $a="|",":","." $b=5,2,1 Do $ = $i mod 20 If $=0 $m="-"+$m Endif For $c = 0 to 2 While $/$b[$c] $m=$a[$c]+$m $=$-$b[$c] Loop Next
$i = $i/20 If $i $m = " " + $m EndIf Until $i=0 Else For Each $c in Split($i) $=0 For $b = 1 to Len($c) $a=SubStr($c,$b,1) $=$+($a=".")+($a=":")*2+($a="|")*5 Next $m=$m*20+$ EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
hmm... this starts to look little like my udf anyways... 264 evolution: Code:
Function m($)
Dim $a,$b,$d $a=".:__|" If $=$+0 Do $d = $ mod 20 If $d=0 $m="-"+$m Endif $b=5 while $b While $d/$b $m=substr($a,$b,1)+$m $d=$d-$b Loop $b=$b/2 loop
$ = $/20 If $ $m = " " + $m EndIf Until $=0 Else For Each $ in Split($) $d=0 For $b = 1 to Len($) $d=$d+instr($a,SubStr($,$b,1)) Next $m=$m*20+$d EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
Ok - I jumped at the easy recurse ...
Benny-259
Code:
Function m($)
Dim $a,$b,$d $a=".:__|" If $=$+0 $d = $ mod 20 If $d=0 $m="-"+$m Endif $b=5 while $b While $d/$b $m=substr($a,$b,1)+$m $d=$d-$b Loop $b=$b/2 loop
$ = $/20 If $ $m = m($) + " " + $m EndIf Else For Each $ in Split($) $d=0 For $b = 1 to Len($) $d=$d+instr($a,SubStr($,$b,1)) Next $m=$m*20+$d EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
227 then. Code:
Function m($b)
Dim $a,$,$d $a=".:__|" If $b=$b+0 $ = $b mod 20 If $=0 $m="-"+$m Endif $d=5 while $d While $/$d $m=substr($a,$d,1)+$m $=$-$d Loop $d=$d/2 loop $ = $b/20 If $ $m =m($) + " " + $m EndIf Else For Each $ in Split($b) For $b = 0 to 19 if m($b) = $ $m=$m*20+$b EndFunction
Re: KiXgolf: Mayan Number Converter - Public Phase
not same result. with that you get 170. I also had a variation of 171. but that's the only one I found that doesn't increase the amount of strokes. but it doesn't lessen them either
Re: KiXgolf: Mayan Number Converter - Public Phase
So, time for the final results. First, there's going to be a rule-change. If another party or two want to complain about anything KiXgolf-related, then this will need to beresolved in person by the involved parties in a nighborhoob bar in lovely Boston, MA, USA, planet Earth, Solar System, Milky Way (just incase soemobdy googles up another Boston ). No-shows loose automatically. Secondly, whoever looses the complaint will have to organize and script the next KiXgolf challenge without being able to compete in it.
So, having said that, here are the results of the private and public round. please keep in mind that points are awared per person, not per submission, thus three submissions by a single person will only result in a single set of points.
Participants (all receive one point): Jooel, Shawn, DrillSergeant, Maciep, Richard H, Allen, Howard Bullock, Glenn Barnas, It_took_my_meds, Jochen, Benny69, Krabourn