Page 1 of 2 12>
Topic Options
#209215 - 2014-07-06 06:03 PM Kixgolf - Win, Win, or Draw - Public Round
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4534
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 Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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 \:\(
_________________________



Top
#209218 - 2014-07-06 06:20 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Jochen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4534
Loc: USA
Oh, and here is the clock for the public round:

Top
#209219 - 2014-07-06 06:33 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Allen]
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
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 \:\)
_________________________
Eric

Top
#209220 - 2014-07-06 07:49 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: maciep]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
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


Edited by Lonkero (2014-07-06 08:10 PM)
_________________________
!

download KiXnet

Top
#209221 - 2014-07-06 08:07 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
Damn. I posted the wrong code.
_________________________
!

download KiXnet

Top
#209222 - 2014-07-06 08:11 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
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.
Top
#209223 - 2014-07-06 10:45 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4534
Loc: USA
What on earth are you doing here with the b+

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

Top
#209224 - 2014-07-06 11:54 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
B equals "" for this purpose. I join the score reverted with length into single string for string comparison and avoiding and-clause.
_________________________
!

download KiXnet

Top
#209225 - 2014-07-07 01:12 AM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4534
Loc: USA
Seriously Lonk, so simple but so eloquent. I like it.
Top
#209226 - 2014-07-07 02:00 AM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
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.
_________________________
!

download KiXnet

Top
#209227 - 2014-07-07 02:14 AM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: maciep]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
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
#209228 - 2014-07-07 06:47 AM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 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



Edited by Jochen (2014-07-07 10:32 AM)
_________________________



Top
#209229 - 2014-07-07 08:18 AM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Jochen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1889
Loc: Hilversum, The Netherlands
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

Top
#209230 - 2014-07-07 01:06 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Arend_]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#209231 - 2014-07-07 01:41 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Howard Bullock]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
Omg. My varnames were different, but that is my old code!

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


Edited by Lonkero (2014-07-07 01:43 PM)
_________________________
!

download KiXnet

Top
#209232 - 2014-07-07 01:41 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Howard Bullock]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
damn, nobody told me that I could just continue the loop until the result was <10
What was I thinking?!
_________________________



Top
#209233 - 2014-07-07 01:49 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
lol. the instructions did. I think calculating the root was not told anywhere and you cleverly deducted that. \:\)
and it never crossed my mind.
_________________________
!

download KiXnet

Top
#209234 - 2014-07-07 05:53 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Lonkero]
Stoke Offline
Fresh Scripter

Registered: 2014-07-02
Posts: 15
Loc: Netherlands
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

Top
#209236 - 2014-07-07 07:34 PM Re: Kixgolf - Win, Win, or Draw - Public Round [Re: Stoke]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4370
Loc: New Jersey
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
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 2 12>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 294 anonymous users online.
Newest Members
MacduMela, karimKix, NicoK, Kelly001, MichaelK72
17776 Registered Users

Generated in 0.071 seconds in which 0.023 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org