Page 1 of 6 12345>Last »
Topic Options
#66570 - 2002-06-10 09:26 PM Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Sorry to be late by my big boss needed help with PowerPoint [Mad]

Here we go:

KiXtart Golf Tournament Part III (Round 2)

Round 2 of the Kixtart Golf tournament has officially opened.

Scripters, post your codes! And steal/modify/improve it!

Here's a recap of the first round:

The task was to write a generic base converter and translate '44680832201' from BASE10 to BASE36.

The result of this translation is KIXTART, or 4468083220110=KIXTART36.

The challange was posted on 08 June 2002 16:40

Shawn announced that he found the answer to the translation task on 08 June 2002 22:40, exactly 6 hours after tournament start.

And here's a timeline of KiXtart golf scores and coders (a star denotes a new leader):

08 June 2002 16:40 = Posting of challange
09 June 2002 04:54 = 379 (Howard Bullock, preliminary solution)
09 June 2002 05:09 = 375 (BrianTX, with a second preliminary solution of score 243)
* 09 June 2002 08:04 = 591 (Howard Bullock, complete working solution)
* 09 June 2002 18:00 = 410 (Shawn)
* 09 June 2002 18:28 = 400 (Shawn)
09 June 2002 18:46 = 446 (Howard Bullock)
09 June 2002 19:35 = 410 (Howard Bullock)
* 09 June 2002 19:59 = 381 (Howard Bullock)
* 09 June 2002 21:07 = 351 (Shawn)
* 09 June 2002 21:53 = 341 (Howard Bullock)
* 09 June 2002 22:07 = 337 (Shawn)
* 09 June 2002 22:34 = 331 (Shawn)
* 09 June 2002 23:03 = 293 (BrianTX)
* 09 June 2002 23:17 = 278 (BrianTX)
09 June 2002 23:11 = 292 (Shawn)
* 09 June 2002 23:29 = 270 (BrianTX)
10 June 2002 00:00 = 355 (Howard Bullock)
* 10 June 2002 00:37 = 267 (BrianTX)
10 June 2002 01:45 = 309 (Howard Bullock)
* 10 June 2002 01:59 = 261 (BrianTX)
10 June 2002 05:58 = 283 (Howard Bullock)
10 June 2002 07:19 = 253 (Howard Bullock, incorrect function name)
10 June 2002 14:31 = 278 (Howard Bullock)

So, the final results for the first round are:
Winner 1) Shawn on 08 June 2002 22:40 announced solution to the translation question
Winner 2) BrianTX with a script scoring 261 on 10 June 2002 01:59

Winner 2) has been changed to BrianTX since Howard admitted that his lowest score script didn't return the answer throught $BaseConverter.

[ 10 June 2002, 21:42: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#66571 - 2002-06-10 09:29 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Here is mine...
code:
FUNCTION BaseConverter($v,$f,$t)
$y = CDBL(1)
$c = ""
$n = 0
FOR $i = LEN($V) TO 1 STEP -1
$x = SUBSTR(UCASE($V),$i,1)
IF
ASC($x) > 57 $x = ASC($x) - 55
ENDIF
$n = $y * $x + $n
$y = $y * $f
NEXT
WHILE $N
$a = INT($n - (INT($n/$t) * $t))
$n = ($n-$a)/$t
IF $a > 9
$a = CHR($a + 55)
ENDIF
$c = "$a$c"
LOOP
$BaseConverter = $c
ENDFUNCTION

Answer to code question:
BaseConverter("44680832201","10","36"):

KIXTART

KixGolf score = 261

Brian

[ 10 June 2002, 21:53: Message edited by: BrianTX ]

Top
#66572 - 2002-06-10 09:32 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This is my leading script.

KixGolf score = 276

Single use only. +5 stroke for multi-use. remove the ";" in front of "Dim"
code:
Function BaseConverter($v,$d,$e)
;Dim $B
$m = '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
$ = CDBL(1)
$i = len($v)
Do
$x = instr($m,substr($v,$i,1))
$j = $ * $x + $j
$ = $ * $d
$i = $i - 1
Until $i = 0

$ = $ / $
do
$ = $ * $e
Until $j < $ * $e
Do
$z = int($j / $)
$B = $B + substr($m,$z,1)
if $j >= $
$j = $j - $ * $z
endif
$ = $ / $e
Until $<1
$BaseConverter=$B
Endfunction
;!
break on
BaseConverter("44680832201",10,36) ?
;BaseConverter("78","11","13") ?
;BaseConverter("2","3","2") ?
;BaseConverter("23423","5","12") ?
;BaseConverter("BrianTX","36","10") ?
;BaseConverter("64","8","2")
;BaseConverter('Kixtart',36,10) ?
;BaseConverter('52',10,2) ?
;BaseConverter('52','10','2') ?

This is my runner up
KixGolf score = 278

Same disclaimer on the "Dim" +5 strokes for multi-use.
code:
Function BaseConverter($v,$d,$e)
;Dim $B
$ = CDBL(1)
$i = len($v)
Do
$x = Asc(ucase(substr($v,$i,1))) - 48
If $x > 9
$x = $x - 7
endif
$j = $ * $x + $j
$ = $ * $d
$i = $i - 1
Until $i = 0

$ = $ / $
do
$ = $ * $e
Until $j < $ * $e
Do
$z = int($j / $)
$x = $z + 48
if $x > 57
$x = $x + 7
endif
$B = $B + chr($x)
if $j >= $
$j = $j - $ * $z
endif
$ = $ / $e
Until $<1
$BaseConverter=$B
Endfunction
;!
break on
BaseConverter("44680832201",10,36) ?
;BaseConverter('Kixtart',36,10) ?
;BaseConverter('52',10,2) ?
;BaseConverter('52','10','2') ?
;BaseConverter("78","11","13") ?
;BaseConverter("2","3","2") ?
;BaseConverter("23423","5","12") ?
;BaseConverter("BrianTX","36","10") ?
;BaseConverter("64","8","2") ?

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

Top
#66573 - 2002-06-10 09:37 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Hmm. If I realized that you could use just $ for a variable, I'd have shaved some more off my score... combining our approaches should get us close to 240ish.. .. Just replacing $n with $ puts my script down to 253..

Brian

[ 10 June 2002, 21:49: Message edited by: BrianTX ]

Top
#66574 - 2002-06-10 09:48 PM Re: Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
First post has been changed to award BrianTX the lowest score winning spot.

Howard, you script is 'interesting' but it breaks after one use [Big Grin]

With regards to the '$' variable, since the script works with it, it's legal. And it's not about beauty anyway [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
#66575 - 2002-06-10 09:48 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I like your solution, Brian. I failed to realize that 0-9 are already numbers [Eek!] in script #1 and #2. I really like your "When $N ... Loop" and your ability to avoid a KiXtart function that requires a "+" for concatenation.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66576 - 2002-06-10 09:50 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If it has to be multi-use, I will remove the comment character before the Dim and take a 5 stroke penalty. [Frown]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66577 - 2002-06-10 09:51 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Thanks. I'm still trying to figure yours out.. the whole:

$ = $ / $ has me a bit confused...

Brian

Top
#66578 - 2002-06-10 09:53 PM Re: Round 2: KiXtart Golf Tournament Part III
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shawn was penalized (perhaps) on the previous game for using $.
See:

Topic: NEW! KiXtart Golf (for the slow days on the board!)

Jens left it a bit vague and should have clarified it. I'd cry foul or at least allow everyone else to rewrite their code using $.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#66579 - 2002-06-10 09:55 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Hey, another thing.. It shouldn't be too hard to write a script that at least checks from 00 base 2 to ZZ base 36 to see if it's accurate.. ..

My check was always to see if the inverse works...

Ya know... BaseConverter(BaseConverter($x,$y,$z)),$z,$y) should be equal to $x, correct?

Brian

P.S. I did it without $ by itself.

[ 10 June 2002, 21:56: Message edited by: BrianTX ]

Top
#66580 - 2002-06-10 09:55 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The "$ = $ / $" was to set $=1 and maintain it as a "Double" without incurring the extra strokes for $=CDBL(1). [(-4) strokes]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66581 - 2002-06-10 09:59 PM Re: Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Personally, I would opt to not allow '$' as a variable. So, let's say a single '$' is not allowed (although it makes the code nicely obscure). But that still makes BrianTX's script the best scorer.
_________________________
There are two types of vessels, submarines and targets.

Top
#66582 - 2002-06-10 10:03 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Hmm. If I can use your "DO" loop instead of my FOR/NEXT it might trim a little off the code... lemme see.... (if you want to do it for me, Howard, that's cool, too)

Brian

{edit}
nope.. I tried it and the script came out 6 longer... unless I did it wrong.

[ 10 June 2002, 22:05: Message edited by: BrianTX ]

Top
#66583 - 2002-06-10 10:07 PM Re: Round 2: KiXtart Golf Tournament Part III
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
This second round is a free-for-all. So, if you see a way to improve a solution (either your own or somebody else's) then go for it.

No holds barred!

Who ever can improve a script the most, shave of the one elusive character, or even come up with a new approach (haven't yet seen a recursive approach) that lowers the score wins the second round.
_________________________
There are two types of vessels, submarines and targets.

Top
#66584 - 2002-06-10 10:10 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I tried recursive, but it was much longer because defining and calling a function takes keystrokes... I honestly don't think you can improve the script much.. although I challenge anyone to try. ($C = "" doesn't matter unless you have a $c in the program you are using, but I put it in there for good measure.)

Brian

Top
#66585 - 2002-06-10 10:26 PM Re: Round 2: KiXtart Golf Tournament Part III
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I also started out with a recursive script, but with a name like BaseConverter() it seemed like a waste of strokes. I will have to revisit it again.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#66586 - 2002-06-10 10:34 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I'm currently borrowing your method of converting from base 10 to base x to see if it makes the code smaller. lol

Brian

{after fiddling with it.. I'm not sure it does}

[ 10 June 2002, 22:44: Message edited by: BrianTX ]

Top
#66587 - 2002-06-10 11:20 PM Re: Round 2: KiXtart Golf Tournament Part III
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hey guys, I'm in between work and taking my daughter to a baseball game, here's three tricks I used:

1) I used the $ thingy too, what I did was to $ the variable with the most references.

2) Since this (my) function has two distinct "sections" - I reused some $vars from the first part - in the second part.

3) Here's a trick I learned to assign doubles:

$y = 1.

$z = 0. + $stringnumber

notice no decimal (implied zero)

Be back later tonight to play !

Way to go guys - should be extremely proud, both of you!

[ 10 June 2002, 23:23: Message edited by: Shawn ]

Top
#66588 - 2002-06-10 11:23 PM Re: Round 2: KiXtart Golf Tournament Part III
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Dang.. that chops off some. I tried Howard's approach with the number list but it doesn't help me.. adds 2 strokes.

Brian

[ 10 June 2002, 23:25: Message edited by: BrianTX ]

Top
#66589 - 2002-06-11 12:06 AM Re: Round 2: KiXtart Golf Tournament Part III
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
thanks to shawn...

I actually have no clue how to implement these new functions...
int/cdbl/fix...
and normal kix numbers do not function.
not even if the result is stored in expression to string.
kix first calculates the result, which overflows allready in the sample mission at the I-char.
which is 2176782336*27=58773123072...
boring!
_________________________
!

download KiXnet

Top
Page 1 of 6 12345>Last »


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

Who's Online
0 registered and 239 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.073 seconds in which 0.025 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