Page 2 of 11 <12345>Last »
Topic Options
#164801 - 2006-07-22 05:16 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Code:

-ubound()



GENIUS...SHEER GENIUS! (spoken in the Tounge of Wile E. Coyote)

Top
#164802 - 2006-07-22 05:19 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
idk, I learned that just a few days ago - when we all golfed-down that sample script in the post where Jen's announced this tournament. My guess is the "IN" variable only gets evaluated once ? I suppose once the enum starts - its not valid to change it on the fly - maybe its a oversight on Ruuds part.
Top
#164803 - 2006-07-22 05:30 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Oops... mis-quoted Mr. Coyote... this is what he really said...

"BRILLIANCE!!! That's all I can say. Sheer unadulterated BRILLIANCE!"

For you young'ans, the Road Runner (Looney Tunes) was the foil to all of Wile E Coyote's brilliant ideas.

Top
#164804 - 2006-07-22 07:29 PM Re: KiXgolf: Mayan Number Converter - Public Phase
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Shawn, very nice with that 185 code. That $m = $m * 20 + ascan($c,$) would have never crossed my mind. And i like the way you built out the mayan numbers - i knew there was room for improvement in the way i did it.

By the way, i was trying to get a half recursive solution going last night, but was too sick of staring at the code

Top
#164805 - 2006-07-22 08:01 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I think there is still room for improvment in that mayan table - somehow getting rid of that 3rd $var - but I can't wrap my mind around it. Or shrinking that mayan string somehow and adding some math-magic - idk . Or something totally new and radical more like.

In terms of the recursive - I did try it "both ways" (to and from at same time) ... and it does work - but I found the overhead on the string side to be too big - but then, that was a few days ago ... one might revisit a double-recurse.

Top
#164806 - 2006-07-22 08:24 PM Re: KiXgolf: Mayan Number Converter - Public Phase
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
I couldn't wait untill tomorrow to see how the public fase went.

I asked the Doc to post my 217 code but he didn't do it yet, so here it is:
Code:
; begin Mayan Number Converter
;
;!
Function m($)
dim $a
If $+0=$
Do
$a = $ mod 20

$m = trim(iif($a, left('.',$ mod 5 mod 2)+ left('::',$ mod 5/2)+left('|||',$a/5),'-')+' '+$m)

$ = $ / 20
Until $ = 0
Else
While $
$a = instr('-.:__|', left($,1))
$m = iif($a, $m+$a-1, $m*20)
$ = right($,~)
EndFunction
;!
;!
; end Mayan Number Converter



I'll be back tomorrow and join in the public fase to see how we can built the ultimate script together.

I had a lot of fun this week, and you can definetly add me to the list for the next kixgolf (or kixpoker? ) round.

Top
#164807 - 2006-07-22 08:39 PM Re: KiXgolf: Mayan Number Converter - Public Phase
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Cause I just woke up dude... LOL
 
Well here is the code for (DrillSergeant, Rogier de Jong) he is out of town right
now and asked that I post the code for him.
 

Function m($)
dim $a
If $+0=$
Do
$a = $ mod 20
$m = trim(iif($a,left('.',$ mod 5 mod 2)+left('::',$ mod 5/2)+left('|||',$a/5),'-')+' '+$m)
$ = $ / 20
Until $ = 0
Else
While $
$a = instr('-.:__|', left($,1))
$m = iif($a, $m+$a-1, $m*20)
$ = right($,~)
EndFunction



 
Code:

Mayan Number Converter passed all 60 tests (100% correct)

KiXtart
KiXtart Version = 4.52
KiXGolf Script = kixgolf_mnc.kix

Computer
OS = Windows XP Professional
CPU = AMD Athlon(tm) 64 FX-53 Processor
Speed = 2403 MHz
Memory = 2046 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Mayan Number Converter
Processing Start = 2006/07/22 11:36:26.421
Processing End = 2006/07/22 11:36:26.421
Duration = 0000/00/00 00:00:00.000
KiXGolf Score = 217

Thank you for participating in KiXtart Golf!


Top
#164808 - 2006-07-22 08:53 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
if $+0 = $

God! Why? Arrrghh

Sarge:

$ = right($,~)

wtf?
_________________________



Top
#164809 - 2006-07-22 10:06 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Cappy, that $ = right($,~) thing ... had to actually run it to figure it out. Its a shorter form of $ = right($,-1). Seems like this:

$ = right("cappy",~)

would return "appy"

That is brilliant.

Top
#164810 - 2006-07-22 10:09 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Well if anything I have learned that I am out of league in this round. Maybe next time...
Top
#164811 - 2006-07-22 10:09 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This aint pretty ... but for a 182 ...

Code:

Function m($)

dim $a,$b,$c

for $b = 1 to 15
$c = split("- . : .: :: | " + $a)
$a = $a + $c[$b] + "| "
next

for each $b in split($)
$m = $m * 20 + ascan($c,$b)
next

if $+0=$
$m = $c[$ mod 20]
if $/20
$m = m($/20) + " " + $m
;endif
;endif

EndFunction


Top
#164812 - 2006-07-22 10:17 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Code:
 $ mod 5 mod 2 



Brilliant (Guiness Guy)
Wow!... a mod mod
I'll have to spend some time figuring out what that does. Nice stuff Serg.

Top
#164813 - 2006-07-22 10:21 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
A mod mod - from a former Mod.
Top
#164814 - 2006-07-22 10:45 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Because of the wicked thunderstorms in the northeast US, I was alternately without power or cable/internet for several hours and was unable to post my lowest score of 326. I've included those enhancements as comments in the code, marked by "LATE! -# strokes". Damn weather made us postpone my daughter's 12th birthday party today!

Somebody asked for commented code so they could learn about the logic, so, here's my commented 337-stroke version:
Code:

; begin Mayan Number Converter
;
;!
Function m($) ; - 57 stroke overhead

Dim $_,$C,$D

If VarType($)=8 ; is it a mayan string?

; Mayan to Decimal - 96 strokes
$D=1 ; initial multiplier value

; work from LSD to MSD
For $_=Len($) to 1 Step -1

; get Mayan char value based on string position
; InString will report 1, 2, 5, or 6 (delimiter)
$C=InStr('.:xx| ',SubStr($,$_,1))

If $C=6 ; Delimiter? move to next multiplier power of 20
$D=$D*20
Else ; is a vaid digit value - multipliy by current multiplier value
; and add to running total
$m=$m+$C*$D ; process value
EndIf

Next ; next string character

Else ; or a Decimal Value?

; Decimal to Mayan - 184 strokes
$D=64000000 ; highest divisor value for 7 digits

While $D>=1 ; loop while divisor is greater than 0
;While $D ; LATE! -3 strokes
; divide by max value, result will be between 0 and 19 - a Mayan "Digit"
$C=$/$D $=$ Mod $D

; If not zero, output the Mayan chars that make up this "digit"
If $C
$m=$m+$_+SubStr('.',1,$C Mod 5 Mod 2)+SubStr('::',1,$C Mod 5/2)+SubStr('|||',1,$C/5)
$_=' ' ; inter-digit space after the first one
Else
; if zero, output a zero only if other digits exist, eliminates leading "shells"
If $m $m=$m+' -' EndIf
EndIf

$D=$D/20 ; reduce the divisor by power of 20

Loop

; If no digits were generated, return only a null shell "digit"
$m=IIf($m='','-',$m)
;$m=IIf($m,$m,'-') ; LATE! -3 strokes

EndIf ; LATE! -5 strokes if removed

EndFunction
;!
;!
; end Mayan Number Converter

_________________________
Actually I am a Rocket Scientist! \:D

Top
#164815 - 2006-07-22 11:00 PM Re: KiXgolf: Mayan Number Converter - Public Phase
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Dang Rogier! A 217 without building out the mayan number...very impressive!
Top
#164816 - 2006-07-22 11:36 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Just using the table generator and the -ubound trick dropped my original function by 21 strokes...

Code:
 
;225
Function m($)
dim $y,$r,$c
for $c = 1 to 15
$y = split("- . : .: :: | " + $r)
$r = $r + $y[$c] + "| "
next
if $+0=$
do
$r=$ mod 20
$m=" "+$y[$r]+$m
$=$/20
until $=0
$m=trim($m)
else
$c=split($)
$r=1
for $=-ubound($c) to 0
$m=$m+ascan($y,$c[-$])*$r
$r=$r*20
; next
; endif
EndFunction



Shawn... I've been staring at your 182... how are you trimming the Mayan number?

Top
#164817 - 2006-07-22 11:40 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
There is no need to trim ... this

if $/20

gives a hint that there are more characters to come ... and since the " " is only added if there are more chars. There is never that "trailing space" that needs to be trimmed.

Top
#164818 - 2006-07-22 11:53 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Rogier, I thought my $i-$i/x($p)*x($p) was creative but your mod mod is a thing of beauty. my hat is off to you.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#164819 - 2006-07-23 12:33 AM Re: KiXgolf: Mayan Number Converter - Public Phase
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Rogier,
I liked your code so I just had to play with it, doing away with $a = $ mod 20 saved you 1 stroke, you now have 216.

Code:

Function m($)
Dim $a
If $+0=$
Do
$m = IIf($ mod 20,Left('.',$ mod 5 mod 2)+Left('::',$ mod 5/2)+Left('|||',$ mod 20/5),'-')+' '+$m
$ = $ / 20
Until $ = 0
Else
$a = InStr('-.:__|', Left($,1))
$m = m(IIf($a, $m+$a-1, $m*20))
$ = Right($,~)
EndFunction



Code:

Mayan Number Converter passed all 60 tests (100% correct)

KiXtart
KiXtart Version = 4.52
KiXGolf Script = kixgolf_mnc.kix

Computer
OS = Windows XP Professional
CPU = Intel(R) Pentium(R) D CPU 2.80GHz
Speed = 2793 MHz
Memory = 2048 MB

KiXGolf Scoring Engine
Scoring Engine = 3.0.3

KiXtart Golf Score
Tournament = KiXtart Golf: Mayan Number Converter
Processing Start = 2006/07/22 17:39:33.831
Processing End = 2006/07/22 17:39:33.846
Duration = 0000/00/00 00:00:00.014
KiXGolf Score = 216



Edited by benny69 (2006-07-23 12:40 AM)

Top
#164820 - 2006-07-23 05:11 AM Re: KiXgolf: Mayan Number Converter - Public Phase
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
After running all submitted codes through my own tester, here's the current results:
Code:

Jooel --------- 182
1. Shawn --------- 185 (confirmed)
2. Shawn --------- 213 (confirmed)
3. DrillSergeant - 217 (confirmed)
Jooel --------- 219
4. Maciep -------- 225 (confirmed)
5. Richard H ----- 252 (confirmed)
6. Allen --------- 256 (confirmed)
7. Howard bullock 285 (confirmed)
8. Glenn Barnas -- 337 (confirmed)
It_took_my_meds 343 (does not pass validation due to not DIMming variables inside the UDF)
9. Jochen -------- 352 (confirmed)
10. Benny69-------- 448 (confirmed)
11. Krabourn ------ 651 (confirmed)


Please note that Jooel has not submitted either of his two solutions, therefore the KiXgolf scores are unconfirmed and thus not reflected in the ranking. As of right now, Shawn would actually be the winner of the private phase.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 2 of 11 <12345>Last »


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

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.16 seconds in which 0.11 seconds were spent on a total of 13 queries. Zlib compression enabled.

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