Extraordinarily well done Rogier, congrats!
My 177 looks like the duck besides the swan compared to it
; 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
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
#181551 - 2007-10-1210:17 AMRe: KiXgolf: Linear Pachinko - Public Round
[Re: DrillSergeant]
DrillSergeantDrillSergeant
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
#181571 - 2007-10-1209:26 PMRe: KiXgolf: Linear Pachinko - Public Round
[Re: DrillSergeant]
DrillSergeantDrillSergeant
MM club member
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
and your 265
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
#181574 - 2007-10-1210:21 PMRe: KiXgolf: Linear Pachinko - Public Round
[Re: Benny69]
DrillSergeantDrillSergeant
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
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...