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.

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

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.

Registered: 2003-01-28
Posts: 4350
Loc: New Jersey

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

EndIf ; LATE! -5 strokes if removed

EndFunction ;! ;! ; end Mayan Number Converter

_________________________ Actually I am a Rocket Scientist!

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?

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.

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne

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

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA

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.

_________________________
There are two types of vessels, submarines and targets.