#202171 - 2011-05-09 03:55 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Allen]
|
Jochen
KiX Supporter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
not at all,
this was what I stumbled over (or similar):
take my last working with 303 :
function a($)
dim $s
$s = 4,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6,6,5,5,5,7,6,6,three,four,five,six,seven,eight,nine,ten,eleven,twelve
$a = "" + $a + $ + " is "
if four=$ | 4=$
$a = $a + magic.
else
if $>99
$ = $s[($^)+25-(($^)>7&instr($,y)>)]
else
$ = $s[iif($<20,$,$/10+18)] + $s[$ mod 10]*($>19&$ mod 10>)
endif
$a = $a + $ + ". " + a($)
endfunction
replacing with an iif() in line 11 (one stroke less) fails with array ref out of bounds if $ > 37 (set $verbose to 2):
function a($)
dim $s
$s = 4,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7,7,9,8,8,6,6,5,5,5,7,6,6,three,four,five,six,seven,eight,nine,ten,eleven,twelve
$a = "" + $a + $ + " is "
if four=$ | 4=$
$a = $a + magic.
else
if $>99
$ = $s[($^)+25-(($^)>7&instr($,y)>)]
else
$ = iif($<20, $s[$], $s[$/10+18]+($ mod 10>)*$s[$ mod 10])
;$s[iif($<20,$,$/10+18)] + $s[$ mod 10]*($>19&$ mod 10>)
endif
$a = $a + $ + ". " + a($)
endfunction
Still can't explain that..
_________________________
|
Top
|
|
|
|
#202173 - 2011-05-09 04:00 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Allen]
|
Jochen
KiX Supporter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#202174 - 2011-05-09 04:20 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Jochen]
|
Glenn Barnas
KiX Supporter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
Here's my code.. only had time for one draft last week and no fine-tuning.function a($)
Dim $T,$v,$l,$n,$f,$z
$T = zero,one,two,three,four,five,six,seven,eight,nine,ten,
eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen,twenty
ReDim Preserve $T[90]
$T[30]=thirty
$T[40]=forty
$T[50]=fifty
$T[60]=sixty
$T[70]=seventy
$T[80]=eighty
$T[90]=ninety
$v=Join(Split(Join(Split($, '-'), ''), ' '), '')
If $ = Val($) ; is numeric
$f=1 ; set flag
$l=Right($,1)
If $<21 ; direct translation
$v = $T[$]
Else ; tens plus ones (if not zero)
$v = $T[10*left($,1)] + IIf($l<>0,$T[$l],'')
EndIf
EndIf
If $v <> four ; don't process if input is "four"
Do
$n = Len($v) ; len of verbose number value
$z=IIf($f,$n, $T[$n]) ; len as either number or verbose value
$a = '' + $a + $ + ' is ' + $Z + '. '
$v = $T[$n] ; reset new verbose value
$=IIf($f,$z,$v)
Until $n = 4
EndIf
$a = $a + IIf($f,'4', 'four') + ' is magic.'
endfunction When I submitted my code I still had a debug message. Actual score without the message was 571 - here's the run from this morning:KiXtart Version = 4.61
KiXGolf Script = kixgolf_fim.kix
Scoring Engine = 3.3
OS = Windows 7 Enterprise Edition
CPU = Intel Pentium Model 14
Speed = 1662 MHz
Memory = 2048 MB
Tournament = Four Is Magic
Processing Start = 2011/05/09 10:11:38.105
Processing End = 2011/05/09 10:11:38.293
Duration = 0000/00/00 00:00:00.187
# Tests Run = 200
# Tests Passed = 200
# Tests Failed =
Result = passed
KiXGolf Score = 571
Thank you for participating in KiXtart Golf! Really interesting solutions (as usual) being posted. I wish I had more time to play.
My concept was to process the words, converting digits to words and reusing the conversion logic.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#202177 - 2011-05-09 07:23 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: ShaneEP]
|
Lonkero
KiX Master Guru
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
how stupid. this what you meant Allen? 275
function a($)
$a=($=)*4,3,3,three,four,five,six,seven,eight,nine,ten,eleven,twelve,8,8,7,7,9,8,8,0,0,6,6,5,5,5,7,6,6
if b>$
$a=($a[$ mod (20-10*($>19))]^)+$a[20+$/10]
else
$a=$a[($^)-(($^)>7&instr($,y)>)]
endif
if four=$ ^ $=4
$a=""+$+" is magic."
else
$a=""+$+" is " + $a +". "+a($a)
endfunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#202178 - 2011-05-09 09:14 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Lonkero]
|
Jochen
KiX Supporter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#202180 - 2011-05-10 02:02 AM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Allen]
|
ShaneEP
MM club member
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Here is my 660 beast Like Glen, I just got a first version, and then a couple mods in...then didn't have as much time as I wanted to work on it after that. Wish I could have gotten it a bit more competitive.
function a($)
dim $1,$2,$3,$s
$1="zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve",
"thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"
$2="","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"
if $=4 OR $="four" AND $>0
$a=""+$+" is magic."
else
if val($)>0 or $=0
if val($)>19
$3=len($2[$/10])+len($1[$ mod 10])
if instr($,0)
$3=$3-4
endif
else
$3=len($1[$])
endif
While $3<>4
$s=""+$s+$+" is "+$3+". "
$=$3
$3=len($1[$3])
Loop
else
$3=$1[Len(join(split(join(split($," "),""),"-"),""))]
While $3<>"four"
$s=$s+$+" is "+$3+". "
$=$3
$3=$1[len($3)]
Loop
endif
$a=""+$s+$+" is "+$3+". "+$3+" is magic."
endif
endfunction
|
Top
|
|
|
|
#202181 - 2011-05-10 02:00 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Allen]
|
Jochen
KiX Supporter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
LOL... that is so funny. However...consider this competition still open... okay .. point taken.
Oh, btw. Jooel, sometimes more is indeed less..
273:
function a($)
dim $b
$b=($=)*4,3,3,three,four,five,six,seven,eight,nine,ten,eleven,twelve,8,8,7,7,9,8,8,0,0,6,6,5,5,5,7,6,6
$a = ""+$+" is "
if four=$|$=4
$a=$a+magic.
else
if b>$
$=($b[$ mod (20-10*($>19))]^)+$b[20+$/10]
else
$=$b[($^)-(($^)*instr($,y)>36)]
endif
$a=$a+$+". "+a($)
endfunction
_________________________
|
Top
|
|
|
|
#202183 - 2011-05-10 09:29 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Lonkero]
|
BradV
Seasoned Scripter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
|
OK, here is my crap code. ![smile \:\)](/forums/images/graemlins/default/smile.gif)
function a($)
dim $s, $t[9], $o[9], $d[9], $w[2], $f, $r, $l, $n
$o = "zero","one","two","three","four","five","six","seven","eight","nine"
$d = $ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"
$t = "","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"
$a = ""
if $ + 0 = $
select
case $ < 10
$w = "","",$o[$]
case $ < 20
$w = "","",$d[$ - 10]
case 1
$r = $ mod 10
$f = int($ / 10)
$w = $t[$f],"-",iif($r = 0,"",$o[$r])
endselect
while not($w[0] = "" and $w[2] = "four")
$l = len($w[0]) + len($w[2])
if $w[0] = ""
if Ascan($d,$w[2]) < 0
$n = Ascan($o,$w[2])
else
$n = Ascan($d,$w[2]) + 10
endif
else
$n = Ascan($t,$w[0]) * 10 + iif($w[2]="",0,Ascan($o,$w[2]))
endif
$a = $a + $n + " is " + $l + ". "
if $l < 10
$w = "","",$o[$l]
else
$w = "","",$d[$l-10]
endif
loop
$a = $a + "4 is magic."
else
if Instr($,"-")
$s="-"
$w = split($,$s)
else
if Instr($," ")
$s=" "
$w = split($,$s)
else
$s=""
$w = $s,$
endif
endif
redim preserve $w[2]
$w[2]=$w[1]
$w[1]=$s
while not($w[0] = "" and $w[2] = "four")
$l = len($w[0]) + len($w[2])
if $l < 10
$n = $o[$l]
else
$n = $d[$l-10]
endif
$a = $a + join($w,"") + " is " + $n + ". "
if $l < 10
$w = "","",$o[$l]
else
$w = "","",$d[$l-10]
endif
loop
$a = $a + "four is magic."
endif
endfunction
|
Top
|
|
|
|
#202184 - 2011-05-10 11:39 PM
Re: Kixgolf - Four Is Magic - Public Round
[Re: BradV]
|
Lonkero
KiX Master Guru
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
271.
function a($)
dim $b
$b=($=)*4,3,3,three,four,five,six,seven,eight,nine,ten,eleven,twelve,8,8,7,7,9,8,8,0,0,6,6,5,5,5,7,6,6
$a = ""+$+" is "
if four=$|$=4
$a=$a+magic.
else
if b>$
$=($b[$ mod (20-10*($>19))]^)+$b[20+$/10]
else
$=$b[($^)-(($^instr($,y))>9)]
endif
$a=$a+$+". "+a($)
endfunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#202185 - 2011-05-11 05:30 AM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Lonkero]
|
Lonkero
KiX Master Guru
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
knew it. no Jochen, Less is MORE ![wink ;\)](/forums/images/graemlins/default/wink.gif)
267
function a($)
$a=($=)*4,3,3,three,four,five,six,seven,eight,nine,ten,eleven,twelve,8,8,7,7,9,8,8,0,0,6,6,5,5,5,7,6,6
if b>$
$a=($a[$ mod (20-10*($>19))]^)+$a[20+$/10]
else
$a=$a[($^)-(($^instr($,y))>9)]
endif
if $=$a
$a=""+$+" is magic."
else
$a="" + $ + " is " + $a + ". "+a($a)
endfunction
_________________________
!download KiXnet
|
Top
|
|
|
|
#202188 - 2011-05-11 08:48 AM
Re: Kixgolf - Four Is Magic - Public Round
[Re: Lonkero]
|
Jochen
KiX Supporter
![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif) ![*](/forums/images/general/default/star.gif)
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 138 anonymous users online.
|
|
|