Page 1 of 4 1234>
Topic Options
#181540 - 2007-10-12 04:13 AM KiXgolf: Linear Pachinko - Public Round
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The public round is open now. Please post your code.
_________________________
There are two types of vessels, submarines and targets.

Top
#181542 - 2007-10-12 04:35 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: Sealeopard]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Well for my blindness to the ball - KiXGolf Score = 481

; begin Linear Pachinko
;
;!

Function a($)
Dim $l,$c,$v,$t,$w

For $l = 1 to Len($)
$c = M($,$l)    

   
Select
        Case $c = "."
            $v = 100
       
Case $c = "|"
            $v = (B($,$l,1) + C($,$l,1)) / 2
       
Case $c = "/"
            $v = B($,$l,1)
       
Case $c = "\"
            $v = c($,$l,1)
       
Case 1
           
$v = 0
   
EndSelect

$t = $t + $v

Next

$a = $t / len($)

EndFunction

Function M($,$r)
$m = substr($,$r,1)
EndFunction


Function b($,$l,$z)
Dim $y

            $y = M($,$l - $z)
           
While $y = "_"
                $z = $z + 1    
               
$y = M($,$l - $z)    
           
Loop
            If $y = "." | $l - $z = 0
               
$b = 100
           
Else
                $b = 0
           


endFunction

Function c($,$l,$z)
Dim $x

            $x = M($,$l + $z)
           
While $x = "_"
                $z = $z + 1
               
$x = M($,$l + $z)
           
Loop
            If $x = "." | $l + $z > Len($)
               
$c = 100
           
Else
                $c = 0
           


EndFunction

;!
;!
; end Linear Pachinko


_________________________
Today is the tomorrow you worried about yesterday.

Top
#181543 - 2007-10-12 06:53 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: Gargoyle]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Here's my 152, I don't know how to present it with nice colors like Gargoyle did...

Gargoyle, I meant to say that you don't have to worry about how the ball rolls, you just have to count the holes and other possibilities \:\)


; begin Linear Pachinko
;
;!
Function a($)
dim $c, $h, $l, $s

$l = $^0

For $c = 3 to 9
$ = Split(x+$+x, Split('_ . x/ \x x|x x| |x')[$c-3])
$s = $s + UBound($) * 100/($c/4)
$a = $s / $l
$ = Join($, $h)
$h = x
EndFunction
;!
;!
; end Linear Pachinko



I'm done commuting in three hours, I'll provide some explanation then (if needed ;\) )



Edited by DrillSergeant (2007-10-12 09:57 AM)
_________________________
The Code is out there

Top
#181544 - 2007-10-12 08:04 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Extraordinarily well done Rogier, congrats! My 177 looks like the duck besides the swan compared to it \:o


; begin Linear Pachinko
;!
function a($)
    dim $b,$c,$d
    $c=0^$
    $=join(split($,_),'')
    $d=1
    while $
        $b=asc($)
        $=right($,~)
        $d=$d+(asc($)<47)
        $a=$a+50*(2*($b=46|$d*($b=47|$b=92))|$d*($b>99))
        $d=$b=46
    loop
    $a=$a/$c
endfunction
;!
;!
; end Linear Pachinko


_________________________



Top
#181545 - 2007-10-12 09:02 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: Jochen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
My 174. I'm already getting Doh! moments looking at some of the tricks in the code that has already been posted.


Function a($p)
Dim $b,$c,$x,$
$c=1
For $a=1 to $p^0
$x=SubStr($p,$a,1)
If $x<>_
$=$+$c*InStr("|/",$x)
$c=0
If $x="."
$=$+2+$b
$c=1
EndIf
$b=InStr("|\",$x)
EndIf
Next
$a=($+$b)*50/($p^0)
EndFunction


Top
#181549 - 2007-10-12 10:11 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: Richard H.]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Richard, for a 173 you can change ($p^0) to ($p^) \:\)
_________________________
The Code is out there

Top
#181551 - 2007-10-12 10:17 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
To provide some information to non-golfers I have two versions of my code in which I've included some explanation of the steps. This code is NOT eligable for golfing in the public round, it's just for informational purposes.

My 198 with explanation:
 Code:
; begin Linear Pachinko
;
;!
Function a($)
dim $c, $d, $h, $l, $x, $y

; Get the length for division.
$l = $^0

; Add a hole to the left and right.
$  = '.' + $ + '.'

; Put all relevant occurences in an array.
$x = _, '.', './', '\.', '.|.', '.|', '|.'

; Assign points for occurences in array $x (floor = 0, mountain side or 
; wall with two holes = 10, wall with single hole = 5). These will be 
;multiplied by 10 later to get 100% or 50%.
$y = 0, 10, 10, 10, 10, 5, 5

; Loop through array $x.
For $c = 0 to 6

	; Split on occurence. The ubound of the array is the number of occurences.
	$  = Split($,$x[$c])
	
	; Add the points to the total (occurences X value X 10).
	$h = $h + UBound($)*$y[$c]*10

	; Join $ again. On the first occurence (floor) it is replaced 
	; with nothing ($d = empty), because we don't need them. 
	$  = Join($,$d)

	; The rest of the occurences are replaced with a single hole.
	$d = '.'
	
	; Divide the total points (minus 200 because of the added left and right
	; holes) by the length of the original $.
	$a = ($h-200) / $l
	
EndFunction
;!
;!
; end Linear Pachinko


My 161 with explanation:
 Code:
; begin Linear Pachinko
;
;!
; I'm setting up an array of all possible occurences. I've
; put the length of the original string in an extra field,
; because that saves me a variable. The use of the other
; fields will be explained later.

; I'm looping from 3 to 9 because of the linear result in
; the calculation ($c/4). this will return the following
; range: 0, 1, 1, 1, 1, 2, 2. 

; In the first run I'm splitting on floor parts. they don't
; have any value (the calculation 100/($c/4) will result in
; 0 (see range above) and I don't want them back in the 
; string, so they will be replaced with an empty var ($h).
; When I've removed the floor parts, the only remaining
; possibilities are the ones that are in the array $o.

; The second run I'm splitting on holes. They always have a
; 100% value, so the calculation will be 100/1 and this is
; added to the total $s. Because the variable $h is now
; filled with an x, all the holes will be replaced with an x.

; the x-es in the split line represent the left and Right
; exits so they will be included in the next evaluations.

; The third to fifth fields in $o are 100% values so they
; are also added to the total. The sixth and seventh fields
; are 50% values, so the calculation results in 2 which gives
; 100/2 = 50.

; After each calculation of $s I generate a $a, but this is 
; just done because of shortness of code. Only after the
; seventh run is $s complete and will the calculation 
; $s / $o[7] ($o[7] being the original length of the string)
; result in the correct return value.
; This explains why I can do without the floor parts. After
; all, if it's not a 100% or a 50% hit, it must be a 0% hit
; (ie a floor part).

Function a($)
dim $c, $h, $s, $o

$o = _, '.', 'x/', '\x', 'x|x', 'x|', '|x', $^0

For $c = 3 to 9
	$  = Split(x+$+x, $o[$c-3])
	$s = $s + UBound($) * 100/($c/4)
	$a = $s / $o[7]
	$  = Join($, $h)
	$h = x
EndFunction
;!
;!
; end Linear Pachinko


Edited by DrillSergeant (2007-10-12 10:18 AM)
_________________________
The Code is out there

Top
#181552 - 2007-10-12 10:43 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I've been watching the codes like \:o \:o \:o
The comments helped me understand what is going on. Thanks Sarg.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#181553 - 2007-10-12 10:51 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Here is my 229. I could never figure out how to do it without 100.0 and the fix().
; begin Linear Pachinko 
; 
;! 
function a($)
  dim $l,$i,$r
  $l=0^$
  $r=split("_cc.c1c\1c11c|/c|0c||c22c1/c11c\|c0|c0|1c21c1|0c12c/c1c\c1c222c2c|c1",c)
  while $i<26
    $=join(split($,$r[$i]),$r[$i+1])
    $i=$i+2
  loop
  while $
    $a=$a+100.0/$l/($ mod 10)
    $=left($,~)
  loop
  $a=fix($a)
endfunction
;! 
;! 
; end Linear Pachinko 

Top
#181558 - 2007-10-12 03:33 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: Allen]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Ok now I understand, Gargoyle and I are the only ones from Earth.

Gargoyle, our solutions are almost the same thought process.

Here is my 288:

 Code:
; begin Linear Pachinko
;
;!
Function a($b)
  Dim $c,$d,$,$x,$y
  
  For $d = 1 to $b^0
    $c=SubStr($b,$d,1)
    $x=f($b,$d,-1)
    $y=f($b,$d,1)
    If $c = '/'
      $=$+$x
    Else
      If $c = \
        $=$+$y
      Else
        If $c = '|'
          $=$+($x+$y)/2
        Else
          If $c = '.'
            $=$+100
          EndIf
;        EndIf
;      EndIf
;    EndIf
;  Next
  $a=$/($b^)
EndFunction
Function f($g,$,$h)
  Dim $j
  
  While $h
    $=$+$h
    $j=SubStr($g,$,1)
    If $j <> _
      $h=0
      If $j = '.' | $ < 1 | $ > ($g^)
        $f=100
;      EndIf
;    EndIf
;  Loop
EndFunction
;!
;!
; end Linear Pachinko
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#181559 - 2007-10-12 03:58 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: Benny69]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Jochens' for 175

 Code:
Function a($b)
    Dim $c,$d,$
    $d=Join(Split($b,_),'')
    $=1
    While $d
        $c=Asc($d)
        $d=Right($d,~)
        $=$+(Asc($d)<47)
        $a=$a+50*(2*($c=46|$*($c=47|$c=92))|$*($c>99))
        $=$c=46
    Loop
    $a=$a/($b^)
EndFunction
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#181570 - 2007-10-12 09:23 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: Benny69]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Benny, here's your 274 \:D

 Code:
; begin Linear Pachinko
;
;!
Function a($b)
Dim $c,$d,$,$x,$y

	For $d = 1 to $b^0
		$c=SubStr($b,$d,1)
;		$x=f($b,$d,-1)
		$x=f($b,$d,~)
		$y=f($b,$d,1)
;		If $c = '/'
			$=$+$x*($c='/')
;		Else
;			If $c = \
				$=$+$y*($c=\)
;			Else
				;If $c = '|'
					$=$+($x+$y)/2*($c='|')
				;Else
;					If $c = '.'
						$=$+100*($c='.')
;					EndIf
;				EndIf
;			EndIf
;		EndIf
;	Next
	$a=$/($b^)

EndFunction

Function f($g,$,$h)
	Dim $j
	
	While $h
		$=$+$h
		$j=SubStr($g,$,1)
		If $j <> _
			$h=0
			If $j = '.' | $ < 1 | $ > ($g^)
				$f=100
;			EndIf
;		EndIf
;	Loop
EndFunction
;!
;!
; end Linear Pachinko



Edited by DrillSergeant (2007-10-12 09:23 PM)
_________________________
The Code is out there

Top
#181571 - 2007-10-12 09:26 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
and your 265 \:D \:D

 Code:
; begin Linear Pachinko
;
;!
Function a($b)
Dim $c,$d,$,$x,$y

	For $d = 1 to $b^0
		$c=SubStr($b,$d,1)
		$x=f($b,$d,~)
		$y=f($b,$d,1)
		$=$+$x*($c='/')+$y*($c=\)+($x+$y)/2*($c='|')+100*($c='.')

	$a=$/($b^)

EndFunction

Function f($g,$,$h)
	Dim $j
	
	While $h
		$=$+$h
		$j=SubStr($g,$,1)
		If $j <> _
			$h=0
			If $j = '.' | $ < 1 | $ > ($g^)
				$f=100
EndFunction
;!
;!
; end Linear Pachinko

_________________________
The Code is out there

Top
#181573 - 2007-10-12 10:19 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Nice Roger!
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#181574 - 2007-10-12 10:21 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: Benny69]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
263 (switched some vars)

Your code has potential, benny... I wouldn't be surprised if we could get this below 250

 Code:
; begin Linear Pachinko
;
;!

Function a($b)
Dim $,$d,$e,$x,$y

	For $d = 1 to $b^0
		$=SubStr($b,$d,1)

		$x=f($b,$d,~)
		$y=f($b,$d,1)
		$e=$e+$x*($='/')+$y*($=\)+($x+$y)/2*($='|')+100*($='.')
		$a=$e/($b^)

EndFunction

Function f($g,$,$h)
	Dim $j
	
	While $h
		$=$+$h
		$j=SubStr($g,$,1)
		If $j <> _
			$h=0
			If $j = '.' | $ < 1 | $ > ($g^)
				$f=100
EndFunction
;!
;!
; end Linear Pachinko

_________________________
The Code is out there

Top
#181581 - 2007-10-13 09:21 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
allen's 227

 Code:
; begin Linear Pachinko 
; 
;! 
Function a($)
dim $l,$i,$r
	$l=0^$
	$r=split("_  . 1 \1 11 |/ |0 || 22 1/ 11 \| 0| 0|1 21 1|0 12 / 1 \ 1 222 2 | 1")
	while $i<26
		$=join(split($,$r[$i]),$r[$i+1])
		$i=$i+2
	loop
	while $
		$a=$a+100.0/$l/($ mod 10)
		$=left($,~)
	loop
	$a=fix($a)
EndFunction
;! 
;! 
; end Linear Pachinko 
_________________________
The Code is out there

Top
#181582 - 2007-10-13 09:33 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
allen's 220
 Code:
; begin Linear Pa hinko 
; 
;! 
Function a($)
dim $l,$i,$r
	$l=0^$
	$r=split("_  . 1 \1 11 |/ |0 || 22 1/ 11 \| 0| 0|1 21 1|0 12 / 1 \ 1 222 2 | 1")
	while $i<26
		$=join(split($,$r[$i]),$r[$i+1])
		$i=$i+2
	Loop
	;? $
	while $
		$a=$a+100/($ mod 10)
		$=left($,~)
	loop
	$a=$a/$l
EndFunction
;! 
;! 
; end Linear Pa hinko 
_________________________
The Code is out there

Top
#181586 - 2007-10-14 12:34 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: DrillSergeant]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Slick! I knew there had to be a way. That's about the only thing I didn't try.
Top
#181592 - 2007-10-14 11:17 AM Re: KiXgolf: Linear Pachinko - Public Round [Re: Benny69]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Originally Posted By: Benny69
Jochens' for 175

 Code:
Function a($b)
    Dim $c,$d,$
    $d=Join(Split($b,_),'')
    $=1
    While $d
        $c=Asc($d)
        $d=Right($d,~)
        $=$+(Asc($d)<47)
        $a=$a+50*(2*($c=46|$*($c=47|$c=92))|$*($c>99))
        $=$c=46
    Loop
    $a=$a/($b^)
EndFunction



Neat, wonder why I haven't thought of that before the deadline
Still can't sit more than half an hour in front of my box after the surgery, so I postpone my efforts on the public round for another day...
_________________________



Top
#181604 - 2007-10-14 11:01 PM Re: KiXgolf: Linear Pachinko - Public Round [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so...
finally got some time in the midst of upgrading one of our servers...

171 out of jochens:

 Code:
Function a($b)
    Dim $c,$d,$
    $d=Join(Split($b,_),'')
    $=1
    While $d
        $c=Asc($d)
        $d=Right($d,~)
        $=$+($d<'/')
        $a=$a+50*(2*($c=46|$*($c=47|$c=92))|$*($c>99))
        $=$c=46
    Loop
    $a=$a/($b^)
EndFunction
_________________________
!

download KiXnet

Top
Page 1 of 4 1234>


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

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.078 seconds in which 0.029 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