AllenAdministrator
(KiX Supporter)
2014-07-06 06:03 PM
Kixgolf - Win, Win, or Draw - Public Round

The private portion of the match is over, and now it is time for the public.

Post up your codes!


JochenAdministrator
(KiX Supporter)
2014-07-06 06:04 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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 \:\(


AllenAdministrator
(KiX Supporter)
2014-07-06 06:20 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Oh, and here is the clock for the public round:


maciep
(Korg Regular)
2014-07-06 06:33 PM
Re: Kixgolf - Win, Win, or Draw - 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 \:\)


LonkeroAdministrator
(KiX Master Guru)
2014-07-06 07:49 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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


LonkeroAdministrator
(KiX Master Guru)
2014-07-06 08:07 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Damn. I posted the wrong code.

LonkeroAdministrator
(KiX Master Guru)
2014-07-06 08:11 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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.

AllenAdministrator
(KiX Supporter)
2014-07-06 10:45 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

What on earth are you doing here with the b+

$=b+(9-$)+($b^)


LonkeroAdministrator
(KiX Master Guru)
2014-07-06 11:54 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

B equals "" for this purpose. I join the score reverted with length into single string for string comparison and avoiding and-clause.

AllenAdministrator
(KiX Supporter)
2014-07-07 01:12 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

Seriously Lonk, so simple but so eloquent. I like it.

LonkeroAdministrator
(KiX Master Guru)
2014-07-07 02:00 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

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.


LonkeroAdministrator
(KiX Master Guru)
2014-07-07 02:14 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

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(,,)


JochenAdministrator
(KiX Supporter)
2014-07-07 06:47 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

 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 totally miss begin to see were you do that though \:o



Arend_
(MM club member)
2014-07-07 08:18 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

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


Howard Bullock
(KiX Supporter)
2014-07-07 01:06 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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


LonkeroAdministrator
(KiX Master Guru)
2014-07-07 01:41 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Omg. My varnames were different, but that is my old code!

Edit. Skip that... Your for to 99 is different...


JochenAdministrator
(KiX Supporter)
2014-07-07 01:41 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

damn, nobody told me that I could just continue the loop until the result was <10
What was I thinking?!


LonkeroAdministrator
(KiX Master Guru)
2014-07-07 01:49 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

lol. the instructions did. I think calculating the root was not told anywhere and you cleverly deducted that. \:\)
and it never crossed my mind.


Stoke
(Fresh Scripter)
2014-07-07 05:53 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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


Glenn BarnasAdministrator
(KiX Supporter)
2014-07-07 07:34 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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
Not sure how much I'll be able to participate in the public round. I'm NOT taking the laptop to the beach! \:D

Glenn


AllenAdministrator
(KiX Supporter)
2014-07-08 03:26 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

No golfing going on?

JochenAdministrator
(KiX Supporter)
2014-07-08 03:54 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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)


JochenAdministrator
(KiX Supporter)
2014-07-08 04:24 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

It would be the first time ever that winner code of private can't be shortened

AllenAdministrator
(KiX Supporter)
2014-07-08 04:44 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Actually this would be the third time. Drill did it once, and Lonk did it last time if my memory serves.

JochenAdministrator
(KiX Supporter)
2014-07-08 05:00 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Oh yeah,
forgot about the last one.. too much confusion there ;\)


LonkeroAdministrator
(KiX Master Guru)
2014-07-09 07:38 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

And that's why it's a wonder why I didn't get my usual fight with drill \:\(

JochenAdministrator
(KiX Supporter)
2014-07-13 11:02 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

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.


LonkeroAdministrator
(KiX Master Guru)
2014-07-13 04:52 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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


LonkeroAdministrator
(KiX Master Guru)
2014-07-13 04:56 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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


LonkeroAdministrator
(KiX Master Guru)
2014-07-14 02:04 AM
Re: Kixgolf - Win, Win, or Draw - Public Round

Hmm... I think it's over

JochenAdministrator
(KiX Supporter)
2014-07-14 03:45 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Damn, I was focused on the calculations, not on the structure

AllenAdministrator
(KiX Supporter)
2014-07-14 04:58 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

Good game. I'll post the scores asap.

LonkeroAdministrator
(KiX Master Guru)
2014-07-14 06:31 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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 \:\)


BradV
(Seasoned Scripter)
2014-07-14 09:48 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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. \:\)

AllenAdministrator
(KiX Supporter)
2014-09-06 08:59 PM
Re: Kixgolf - Win, Win, or Draw - Public Round

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.