Page 2 of 5 <12345>
Topic Options
#202169 - 2011-05-09 03:37 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Jochen, I guess I am getting old and blind already \:\)
_________________________
!

download KiXnet

Top
#202170 - 2011-05-09 03:44 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
In between holes, lets talk about the errors you guys were running into.

I may know the one Jochen ran into. I actually asked a question about it about 8 months ago, when I first started putting this together: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Main=26945&Number=199573#Post199573

Top
#202171 - 2011-05-09 03:55 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

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 :

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

 Code:
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
#202172 - 2011-05-09 03:57 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Jochen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I forgot you had that one... it was early on when you had one failing test that I was thinking of.
Top
#202173 - 2011-05-09 04:00 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Allen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh yeah, you're right. First it evaluated true even if $ was 0 .. But a quick "if four=$ | 4=$" solved the variant type problem ;\)

Oh well, in reality I had a very long time this instead

 Code:
if $=4 | $=four & $>0


then .. for a shorter period this:

 Code:
if instr(four4,$)




Edited by Jochen (2011-05-09 04:06 PM)
_________________________



Top
#202174 - 2011-05-09 04:20 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

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.
 Code:
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:
 Code:
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! \:D

Top
#202175 - 2011-05-09 04:31 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Jochen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Sorry I havent been home much in the last couple days. And I don't have my newest code here at work.
Top
#202176 - 2011-05-09 04:31 PM Re: Kixgolf - Four Is Magic - Public Round [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
I can post my 703 version if you want.
Top
#202177 - 2011-05-09 07:23 PM Re: Kixgolf - Four Is Magic - Public Round [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
how stupid. this what you meant Allen?
275
 Code:
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 Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
OMG !!!!!
We've talked about variant types and I didn't see the forrest for the trees..

If I think of how many times I tried "if $>a" or "if $>b" .. GAWD!!

really stupid, that


Edited by Jochen (2011-05-09 09:18 PM)
_________________________



Top
#202179 - 2011-05-10 12:20 AM Re: Kixgolf - Four Is Magic - Public Round [Re: Jochen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
LOL... that is so funny. However...consider this competition still open...
Top
#202180 - 2011-05-10 02:02 AM Re: Kixgolf - Four Is Magic - Public Round [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

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.

 Code:
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 Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Originally Posted By: Allen
LOL... that is so funny. However...consider this competition still open...

okay .. point taken.

Oh, btw. Jooel, sometimes more is indeed less..

273:
 Code:
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
#202182 - 2011-05-10 05:34 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh. darn.
_________________________
!

download KiXnet

Top
#202183 - 2011-05-10 09:29 PM Re: Kixgolf - Four Is Magic - Public Round [Re: Lonkero]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
OK, here is my crap code. \:\)

 Code:
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 Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
271.
 Code:
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 Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
knew it.
no Jochen, Less is MORE ;\)

267

 Code:
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
#202186 - 2011-05-11 05:34 AM Re: Kixgolf - Four Is Magic - Public Round [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no... Less is ... how did it go? \:\/
_________________________
!

download KiXnet

Top
#202187 - 2011-05-11 06:30 AM Re: Kixgolf - Four Is Magic - Public Round [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Dang...you guys should start adding comments into your code so lowly scripters like myself can know what's going on.
Top
#202188 - 2011-05-11 08:48 AM Re: Kixgolf - Four Is Magic - Public Round [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
hehe, nice one ..

 Code:
if $=$a



now it starts getting hard \:D


Edited by Jochen (2011-05-11 08:55 AM)
_________________________



Top
Page 2 of 5 <12345>


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

Who's Online
0 registered and 231 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.046 seconds in which 0.013 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