Page 1 of 11 12345>Last »
Topic Options
#164781 - 2006-07-22 02:03 PM KiXgolf: Mayan Number Converter - Public Phase
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Gentlemen, the private phase is now closed. Please show your hands, ahem, your code.

The preliminary ranking of the private phase, pending verification of the codes for all participants is as follows:
Code:

1. Jooel --------- 182
2. Shawn --------- 213
3. DrillSergeant - 217
4. Jooel --------- 219
5. Maciep -------- 225
6. Richard H ----- 252
7. Allen --------- 256
8. Howard bullock 285
9. Glenn Barnas -- 337
10. It_took_my_meds 343
11. Jochen -------- 352
12. Benny69-------- 448
13. Krabourn ------ 651



Let the hacking begin...
_________________________
There are two types of vessels, submarines and targets.

Top
#164782 - 2006-07-22 02:11 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
This is the submission from Richard Mallesch (it_took_my_meds), which I am posting on his behalf:
Code:

Function m($a)

$l=0,5,2,1,0
$v="|",":",".","-"
$n = 1
If AScan($v,Left($a,1))=-1
Do $ = $a Mod ($n*20)
$a = $a - $
$ = $ / $n
$n = $n * 20
If $
For $q = 1 to 3
While $ / $l[$q]
$m=$v[$q-1]+$m
$=$-$l[$q]
Loop
Next
Else
$m="-"+$m
EndIf
$m=" "+$m
Until $a=0
$m=Trim($m)
Else
$a = " "+$a
While $a
$c=Right($a,1)
$=IIf($c=" ",-$,$+$l[AScan($v,$c)+1])
$a=Left($a,~)
If $<0 Or $c="-"
$m = $m - $n * $
$n = $n * 20
$=0
;EndIf
;Next
;EndIf

EndFunction



Note: The code does not pass the validation as the variables inside the UDF are not declared despite "$iRC=SETOPTION('Explicit','on')" defined in kixgolf_mnc.kix
_________________________
There are two types of vessels, submarines and targets.

Top
#164783 - 2006-07-22 02:12 PM Re: KiXgolf: Mayan Number Converter - Public Phase
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
Only fitting that the highest scrore be posted first. HAHAHA!!!

Code:
FUNCTION m($)
DIM $a[6], $b, $i, $j, $t, $s, $u
IF InStr(".:|-", SubStr($, 1, 1))
$a = Split($)
$u = UBound($a)
FOR $i = 0 TO $u
$t = 0
FOR $j = 1 TO Len($a[$i])
$b = SubStr($a[$i], $j, 1)
$t = $t + IIf($b = ".", 1, IIf($b = ":", 2, IIf($b = "|", 5, 0)))
NEXT
$s = 1
IF $u - $i
$s = 20
FOR $j = 1 TO $u - $i - 1
$s = $s * 20
NEXT
ENDIF
$m = $m + $s * $t
NEXT
ELSE
DO
IF $ > 19
$s = 1
FOR $i = 1 TO 6
$s = $s * 20
IF $s < $
$j = $i
$t = $s
ENDIF
NEXT
IF $ > 19
FOR $i = 1 TO 20
$s = $t
$s = $s * $i
IF $s <= $
$a[$j] = $i
ENDIF
NEXT
ELSE
$t = $
ENDIF
$ = $ - ($t * $a[$j])
ELSE
$a[0] = $
$ = $ - $
ENDIF
UNTIL $ < 1
FOR $i = 6 TO 0 STEP -1
IF $a[$i] = "" AND $i
REDIM PRESERVE $a[$i - 1]
ELSE
$i = -1
ENDIF
NEXT
FOR EACH $ IN $a
DO
$m = IIf($ > 4, "|", IIf($ > 1, ":", IIf($, ".", "-"))) + $m
$ = $ - IIf($ > 4, 5, IIf($ > 1, 2, IIf($, 1, 0)))
UNTIL $ < 1
$m = " " + $m
NEXT
$m = Trim($m)
ENDIF
ENDFUNCTION



Oop! Guess I was not fast enough.


Edited by krabourn (2006-07-22 02:16 PM)

Top
#164784 - 2006-07-22 02:19 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Right,

here's my 352 still with vartype()

Code:

function m($)
dim $a, $b, $c, $p
$a = split('- . : .: :: | .| :| .:| ::| || .|| :|| .:|| ::|| ||| .||| :||| .:||| ::|||')
$p = 64000000, 3200000, 160000, 8000, 400, 20, 1
if vartype($) = 3
for $b = 0 to 6
$c = $p[$b]
$m = iif($ >= $c, trim($m + ' ' + $a[$/$c]), iif($m, $m + " -", $m))
$ = $ - $/$c * $c
next
$m = iif($m, $m, '-')
else
$c = split($)
$ = ubound($c)
for $b = 0 to $
$m = $p[6-$+$b] * ascan($a,$c[$b]) + $m
;next
;endif
endfunction



[edit]
in the make I had a helper udf for power of 20, as well as a programmatic building
of the mayan string; Something like this:
$m = $m + left('.',( $} - $}/5) mod 2 ) + left('::',( $}-5*($}/5))/2) + left('|||',$}/5) + ' '
(where $} = $/${ , and ${ = p(6-$e) in a for 0 to 6)
which was of course too long.
That said, have a very nice weekend gentlemen, see you on monday
[/edit]


Edited by Jochen (2006-07-22 02:27 PM)
_________________________



Top
#164785 - 2006-07-22 02:23 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
A little comment on the challenge. The Mayan Number Converter basically consists of two transformations. Transformation #1 is the conversion of the Mayan symbols into a decimal number representation. Transformation #2 is a BASE20/BASE10 conversion between the Mayan vigesimal and the decimal numeral system.

A generic Base Converter is available in the UDF Section under BaseConverter() - for base2-base36 conversions
_________________________
There are two types of vessels, submarines and targets.

Top
#164786 - 2006-07-22 02:27 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Current standings after validating the already posted codes.
Code:

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

_________________________
There are two types of vessels, submarines and targets.

Top
#164787 - 2006-07-22 02:38 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Here is my 448, the additional UDF 'x($)'is the power calculator and both UDF's were placed between ;!,... ;! so that it was included in the count calc:

Code:

Function m($i)
Dim $a,$b,$c,$,$p

If VarType($i)=8
$i=Split($i)
For $c = UBound($i) to 0 Step-1
$=0
For $b = 1 to Len($i[$c])
$a=SubStr($i[$c],$b,1)
$=$+($a=".")
$=$+($a=":")*2
$=$+($a="|")*5
Next
$m=$m+$*x($p)
$p=$p+1
Next
Else
$p=1
Do
$b=$i-$i/x($p)*x($p)
$=$b/x($p-1)
If $=0
$m="-"+$m
Else
For $c=1 to $/5
$m="|"+$m
$=$-5
Next
For $c=1 to $/2
$m=":"+$m
$=$-2
Next
If $=1
$m="."+$m
$=$-1
EndIf
EndIf
$i=$i-$b
$p=$p+1
If $i>0
$m=" "+$m
EndIf
Until $i=0
EndFunction

Function x($)
Dim $y
$x=1
For $y = 1 to $
$x=$x*20
EndFunction

_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

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

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Here's my code for a score of 225

Code:

Function m($)
dim $c,$d,$f
$f = '- . : .: :: | '
$f = split($f+$f+$f)
for $c=6 to 19
$f[$c]=$f[$c-5]+'|'
next
if $+-$=0
do
$m = trim($f[$ mod 20] + ' ' + $m)
$ = $/20
until $=0
else
$ = split($)
for $d = -ubound($) to 0
$m = $m + $c/20 * ascan($f,$[-$d])
$c=$c*20
;next
;endif
EndFunction


Top
#164789 - 2006-07-22 03:45 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
My god Eric - our code is almost identical:

My 213 is:

Code:

Function m($)

dim $a,$b,$c

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

if $+0=$
$m = $c[$ mod 20]
if $/20
$m = m($/20) + " " + $m
endif
else
$ = split($)
$b = 1
for $a = -ubound($) to 0
$m = $m + $b * ascan($c,$[-$a])
$b = $b * 20
;next
;endif

EndFunction



This is my new public coding submission for a score of 185

Code:

Function m($)

dim $a,$b,$c

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

if $+0=$
$m = $c[$ mod 20]
if $/20
$m = m($/20) + " " + $m
endif
else
for each $ in split($)
$m = $m * 20 + ascan($c,$)
;next
;endif

EndFunction



By the way - I am officially protesting Jooels submission of 182. Jens - your going to have to verify it - none of us have time to do it - and if he does win - I figure the public golfing of it would take - like - 100 years !

Top
#164790 - 2006-07-22 03:59 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
285...
Code:
 ; begin Mayan Number Converter
;
;!
Function m($)
dim $a,$b,$c,$p
if $=$+0
do
$b = $ mod 20
$=($-$b)/20

if $b
$a=5,2,1
for each $p in $a
while $b/$p>0
$m=substr(".:zz|",$p,1)+$m
$b=$b-$p
loop
next
else
$m="-"+$m
endif
$m=" "+$m
until $=0
$m=ltrim($m)
else
$c=1
for $a=len($) to 1 step -1
$b=substr($,$a,1)

if $b=" "
$c=$c*20
endif
$m=$c*instr(".:zz|",$b)+$m

EndFunction
;!
;!
; end Mayan Number Converter

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#164791 - 2006-07-22 04:23 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Very elegant Shawn.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#164792 - 2006-07-22 04:24 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
This latest challenge was probably more interesting and fun that most of those we've had recently as it lends itself to many different paths to the solution.

I've discovered a few new techniques and tricks that surprised me, world weary old cynic that I am.

Anyhoo, here it is. Not the shortest, but a thing of chiaroscuric beauty none-the-less (in the authors humble opinion )

Code:
; begin Mayan Number Converter
;
;!
Function m($n)
Dim $,$c
If $n=Val($n)
Do
$=$n mod 20
$n=$n/20
Do
$c=($>4)*3+IIf($>1,2,$)
$=$-$c
$m=SubStr("-.:xx|",$c+1,1)+$m
Until $=0
$m=" "+$m
Until $n=0
Else
For Each $ in Split($n)
$m=$m*20
While $
$m=$m+InStr(".:xx|",Left($,1))
$=SubStr($,2)
Loop
Next
EndIf
$m=Trim($m)
EndFunction
;!
;!
; end Mayan Number Converter
; vim600:filetype=kix ai sw=4 ts=4


Top
#164793 - 2006-07-22 04:35 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Richard, I see we think alike.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#164794 - 2006-07-22 04:38 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
256

Code:

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


Top
#164795 - 2006-07-22 04:42 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Allen Administrator Online   shocked
KiX Supporter
*****

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

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



Shawn... so simple...yet... I spent hours and never thought of that...

Top
#164796 - 2006-07-22 04:46 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I'll have to go offline for most of th day. Please continue posting your entreis for the private phase so that I can validate them. And, FYI, I have my own tests, additional combinations that I'm running. Plus, code has to finish within the timeframe for the tournament.
_________________________
There are two types of vessels, submarines and targets.

Top
#164797 - 2006-07-22 04:47 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's some golf tips for the public round - assuming your going to maybe start with the 185 code:

1) The best opportunity for removing strokes (imho) is here:

Code:

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



If anyone can find a shorter way to build a mayan character table - it will be gold.

The other place is here:

Code:

if $+0=$



If anyone can find a shorter numeric check or b) find a similar or shorter way to test for STRING instead. If you can find a string check - then one should be able to flip the code blocks around - probably saving a single stroke on the commented-out nexts and endif's

One word of caution - this here:

Code:

$m = m($/20) + " " + $m



is a recursive call - so things like IIF() will not work. IIF expressions always get evalulated so using them can cause an endless recurse. Of course - thats just been my experience ;o)

-Shawn

Top
#164798 - 2006-07-22 04:55 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
More about that table ...

Code:

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



If one is able to bring the number of $vars down from 3 to 2 - and still keep the same number of strokes - then one should be able to remove the DIM of the $var - and save like three strokes !

I've been staring at this table for days - with zero luck.

For reference - here is the absolute max way of defining the table:

$c = split("- . : .: :: | .| :| .:| ::| || .|| :|| .:|| ::|| ||| .||| :||| .:||| ::|||")

Top
#164799 - 2006-07-22 04:56 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Richard, I see we think alike.




You're not fooling me, I know that you are just another voice in my head and I am the real Howie

Shhhhh! Hush my brother, they are ever listening...

Top
#164800 - 2006-07-22 05:02 PM Re: KiXgolf: Mayan Number Converter - Public Phase
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Why does the following work? Maybe I stayed up too late night and just can't think straight, but why isn't "$" redefined and fail on the next iteration.

Code:
 for each $ in split($) 


Code:
$="1 2 3 4 5"
? Vartypename($)
? $
for each $ in split($)
? $
? Vartypename($)
next
? Vartypename($)
? "$$="+$


The original value of "$" is set to Empty after the loop.


Edited by Howard Bullock (2006-07-22 05:16 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 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 896 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.154 seconds in which 0.105 seconds were spent on a total of 12 queries. Zlib compression enabled.

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