#209215 - 2014-07-06 06:03 PM
Kixgolf - Win, Win, or Draw - Public Round
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
The private portion of the match is over, and now it is time for the public.
Post up your codes!
|
Top
|
|
|
|
#209216 - 2014-07-06 06:04 PM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: Allen]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
for 267
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
_________________________
|
Top
|
|
|
|
#209219 - 2014-07-06 06:33 PM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: Allen]
|
maciep
Korg Regular
Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
|
298
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
_________________________
Eric
|
Top
|
|
|
|
#209227 - 2014-07-07 02:14 AM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: maciep]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
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(,,)
_________________________
!download KiXnet
|
Top
|
|
|
|
#209229 - 2014-07-07 08:18 AM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: Jochen]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
Here's my monstrosity for 462:
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
|
Top
|
|
|
|
#209230 - 2014-07-07 01:06 PM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: Arend_]
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
257
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
|
Top
|
|
|
|
#209234 - 2014-07-07 05:53 PM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: Lonkero]
|
Stoke
Fresh Scripter
Registered: 2014-07-02
Posts: 15
Loc: Netherlands
|
This was my 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
|
Top
|
|
|
|
#209236 - 2014-07-07 07:34 PM
Re: Kixgolf - Win, Win, or Draw - Public Round
[Re: Stoke]
|
Glenn Barnas
KiX Supporter
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
Left for vacation with this 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 Not sure how much I'll be able to participate in the public round. I'm NOT taking the laptop to the beach!
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 255 anonymous users online.
|
|
|