|
|
|||||||
The private portion of the match is over, and now it is time for the public. Post up your codes! |
||||||||
|
|
|||||||
for 267 Code: function a($r) dim $x, $c, $l $c = 9 for each $r in split($r,',') dim $, $s $s = lcase($r) while $s $ = $+asc($s)-48-48*($s>Z) $s = right($s,~) loop do $ = $/10+$ mod 10 until $<10 $a = $a+$r+'='+$+', ' $s = $l-($r^) if $s=0&$=$c $x = Draw endif if $<$c|$s<0&$=$c $x = 'Winner='+$r $l = $r^0 $c = $ endif next $a = $a+$x endfunction what annoys me most are all the closing keywords |
||||||||
|
|
|||||||
Oh, and here is the clock for the public round: |
||||||||
|
|
|||||||
298 Code: function a($) dim $b,$t,$s,$w,$c,$d,$e $d=z for each $b in split($,',') $w=$b do $t=0 while $b $s=asc(lcase(left($b,1)))-96 $t=$t+iif($s>0,$s,$s+48) $b=right($b,~) loop $b=$t until $t<10 $s=len($w) if $d>$t | ($t=$d & $s>$c) $d=$t $c=$s $e='Winner='+$w else if $t=$d & $s=$c $e=Draw endif endif $a=$a+$w+'='+$t + ', ' next $a=$a+$e endfunction I can already tell from Jochen's code how many strokes I left in mine...but I knew my swing was a little rusty this time out |
||||||||
|
|
|||||||
223 Code: function a($) dim $D,$r,$b for each $ in split($,',') $b=$ do dim $t while $ $t=$t+ (asc($) mod 96 & 63) mod 48 $=right($,~) loop $=$t until 10>$ $a=$a+$b+'='+$+', ' $=b+(9-$)+($b^) if $D=$ $r=Draw endif if $>$D $D=$ $r='Winner='+$b endif next $a=$a+$r endfunction |
||||||||
|
|
|||||||
Damn. I posted the wrong code. |
||||||||
|
|
|||||||
Fixes d the above as 223. If it doesn't work let me know and I will get back on the computer to fetch the file. |
||||||||
|
|
|||||||
What on earth are you doing here with the b+ $=b+(9-$)+($b^) |
||||||||
|
|
|||||||
B equals "" for this purpose. I join the score reverted with length into single string for string comparison and avoiding and-clause. |
||||||||
|
|
|||||||
Seriously Lonk, so simple but so eloquent. I like it. |
||||||||
|
|
|||||||
maybe I could shave some of mine if I understood what the heck jochen is doing with " do $ = $/10+$ mod 10 until $<10" that does not make any sense to me. he was able to skip subsequent additions by doing a mod 10. |
||||||||
|
|
|||||||
Eric, Your code looks exactly like mine around 290 ish. except I don't do that deep indents. oh, and I never did iif. per old golf rules, if you are not forced to use if-else-endif, all of it, you are wasting strokes by using iif. so, $t=$t+iif($s>0,$s,$s+48) would be $t=$t+$s+48*($s<) which would only help you by 7. which is exactly the amount required to even spell skeleton iif(,,) |
||||||||
|
|
|||||||
Originally Posted By: Lonkero maybe I could shave some of mine if I understood what the heck jochen is doing with " do $ = $/10+$ mod 10 until $<10" that does not make any sense to me. he was able to skip subsequent additions by doing a mod 10. Simple.. $/10 cuts the last digit + $ mod 10 adds the last digit so all it does is calculating the digital root of numbers up to 32bit integer I |
||||||||
|
|
|||||||
Here's my monstrosity for 462: Code: function a($) Dim $s, $k, $d, $x, $y, $w, $u, $v $s=Split($,",") $d=$s $x=$s[0] $y=10 For $k=0 To UBound($d) Dim $q $q=$d[$k] $a=$a+$q+"=" Do Dim $i, $r, $p, $t For $i=1 to Len($q) $t=SubStr($q,$i,1) $p=Asc(UCASE($t))-64 $r=$r+IIF($p < 0,CInt($t),$p) Next $q=$r Until LEN($q) = 1 $a=$a+$q+", " $u=Len($s[$k]) $v=Len($x) Select Case Cint($q) < $y ReDim $w $y = $q $x = $s[$k] Case $q = $y If $u > $v $w="Winner="+$s[$k] EndIf If $u < $v $w="Winner="+$x EndIf If $u = $v $w="Draw" EndIf EndSelect Next If NOT $w $w="Winner="+$x EndIf $a=$a+$w endfunction |
||||||||
|
|
|||||||
257 Code: function a($b) dim $c,$d,$i,$j,$k,$m,$ $i=9 for each $c in split($b,',') $d=len($c) $m=$c ;Calculate the value of the string until it is a single digit do $=0 for $a=1 to 99 ;len($m) $=$+ASC(substr(lcase($m),$a,1)) mod 48 next $m=$ until $<10 ;Build output line: items + scores $k=$k+$c+"="+$+", " ;Track score and add final output text ;Define 'Draw' as score and length equal if $i=$ & $d=$j $b="Draw" endif ;Define Winner as 'score is lower' or 'score =' and 'word longer' if $i>$ | $i=$ & $d>$j $i=$ $j=$d $b="Winner="+$c endif ;Add result to output line $a=$k+$b endfunction |
||||||||
|
|
|||||||
Omg. My varnames were different, but that is my old code! Edit. Skip that... Your for to 99 is different... |
||||||||
|
|
|||||||
damn, nobody told me that I could just continue the loop until the result was <10 What was I thinking?! |
||||||||
|
|
|||||||
lol. the instructions did. I think calculating the root was not told anywhere and you cleverly deducted that. and it never crossed my mind. |
||||||||
|
|
|||||||
This was my code Code: ; begin WWD ; ;! function a($) Dim $w,$r,$1,$d,$s, $o $s = 10 For Each $w in Split($,",") Dim $v,$i,$t,$l $t=$w $l = Len($w) While Len($t) <> 1 OR $t > 9 Dim $n For $i=1 to Len($t) $v= Substr(UCASE($t), $i,1) $v = Iif(asc($v) <58,$v, Asc($v)-64) $n = $n + Int($v) Next $t = $n Loop $r = $r +$w+"="+$t+", " $o=Len($1) If $t <= $s $d = ($s = $t & $o = $l) $1 = Iif($s > $t,$w,Iif(($o > $l),$1,$w)) $s = int($t) Endif Next $a=($r +Iif($d,"Draw", "Winner="+$1)) endfunction ;! ;! ; end WWD |
||||||||
|
|
|||||||
Left for vacation with this code: Code: ; begin WWD ; ;! function a($) ; $ - Array of source data, WWD Value of Current String ; $A - Function Return Value ; $C - Character being evaluated ; $I - Index Pointer ; $L - Length of current string ; $P - Char Pointer ; $V - Current String ; $X - WWD Winning String ; $Y - WWD Winning Value ; $Z - Win/Draw text Dim $C,$I,$L,$P,$V,$X,$Y,$Z $X = 0 $Y = 99 ; init LOW value For Each $V In Split($, ',') ; process each value in list $L = Len($V) ; get length $ = 0 ; Init WWD value of current string For $P = 1 to $L ; enumerate the string parts $C = Asc(SubStr(UCase($V), $P, 1)) - 48 ; get ASCII value $ = $ + IIf($C < 10, $C, $C - 16) ; set index value & add to prior Next While $ > 9 ; process multi-digit values $I = IIf($ > 109, 1, 0) ; middle digit? ; $I = IIf($ > 109, Val(SubStr($,2,1)),0) $ = $I + Left($,1) + Right($,1) Loop $A = $A + $V + '=' + $ + ', ' ; Create output string ; Process the current value and determine the WWD status $I = Len($X) If $ < $Y ; Is current WWD < prior WWD? $X = $V ; set current winning string $Y = $ ; set current winning value $Z = 'Winner=' Else If $ = $Y If $I = $L $X = '' $Y = $ $Z=Draw Else If $I < $L $X = $V ; set current winning string $Y = $ ; set current winning value $Z = 'Winner=' EndIf EndIf EndIf EndIf Next $A = $A + $Z + $X ; Create output string ;$A ? ? endfunction ;! ;! ; end WWD Glenn |
||||||||
|
|
|||||||
No golfing going on? |
||||||||
|
|
|||||||
Hmm .. Jooels code seems tight. And as the others are similar all we can do is to transform them to Jooels (seems futile to me) But, I'll have another look at Jooels later this week (if time allows) |
||||||||
|
|
|||||||
It would be the first time ever that winner code of private can't be shortened |
||||||||
|
|
|||||||
Actually this would be the third time. Drill did it once, and Lonk did it last time if my memory serves. |
||||||||
|
|
|||||||
Oh yeah, forgot about the last one.. too much confusion there |
||||||||
|
|
|||||||
And that's why it's a wonder why I didn't get my usual fight with drill |
||||||||
|
|
|||||||
Ok, giving up on Jooels code.. no more improvements possible (at least for me) Congratulations. Fun round this one, a bit lacking on public, but fun anyway Looking forward to the next one. |
||||||||
|
|
|||||||
was worth the extra time this morning... 222! Code: function a($) dim $D,$r,$b,$n for each $ in split($,',') $b=$ do dim $t while $ $t=$t+ (asc($) mod 96 & 63) mod 48 $=right($,~) loop $=$t until 10>$ $n=$n+$b+'='+$+', ' $=b+(9-$)+($b^) if $D=$ $r=Draw endif if $>$D $D=$ $r='Winner='+$b endif $a=$n+$r endfunction |
||||||||
|
|
|||||||
219 Code: function a($) dim $D,$r,$n for each $ in split($,',') $a=$ do dim $t while $ $t=$t+ (asc($) mod 96 & 63) mod 48 $=right($,~) loop $=$t until 10>$ $n=$n+$a+'='+$+', ' $=b+(9-$)+($a^) if $D=$ $r=Draw endif if $>$D $D=$ $r='Winner='+$a endif $a=$n+$r endfunction |
||||||||
|
|
|||||||
Hmm... I think it's over |
||||||||
|
|
|||||||
Damn, I was focused on the calculations, not on the structure |
||||||||
|
|
|||||||
Good game. I'll post the scores asap. |
||||||||
|
|
|||||||
Jochen, I was too focusing on the calculations. $=$-0.01*($b^) being one of the prettiest, but only got to 227 with that. but, at least we can smile on the fact that I was FINALLY able to remove one ending tag |
||||||||
|
|
|||||||
Just got back from vacation. Looks like I missed it. I was trying to write a recursive algorithm. Probably would have been around 923 or so. |
||||||||
|
|
|||||||
Sorry for the long delay. Scores! Code: Private Round Jooel 223 5 1 Howard 257 4 1 Jochen 267 3 1 Maciep 298 2 1 Stoke 368 1 1 Glenn 375 0 1 Arend 462 0 1 Drill *** 0 1 Public Round Jooel 219 5 1 Howard 257 4 0 Jochen 267 3 0 Maciep 298 2 0 Stoke 368 1 0 Glenn 375 0 0 Arend 462 0 0 Drill *** 0 0 Total Points Jooel 12 Howard 9 Jochen 7 Maciep 5 Stoke 3 Glenn 1 Arend 1 Drill 1 *** Drill did not submit his code. |