#66570 - 2002-06-10 09:26 PM
Round 2: KiXtart Golf Tournament Part III
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
Sorry to be late by my big boss needed help with PowerPoint
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
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
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") ?
|
Top
|
|
|
|
#66573 - 2002-06-10 09:37 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66575 - 2002-06-10 09:48 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
Howard Bullock
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 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.
|
Top
|
|
|
|
#66576 - 2002-06-10 09:50 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
Howard Bullock
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.
|
Top
|
|
|
|
#66577 - 2002-06-10 09:51 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66579 - 2002-06-10 09:55 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
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]
|
Top
|
|
|
|
#66582 - 2002-06-10 10:03 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66584 - 2002-06-10 10:10 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
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.
|
Top
|
|
|
|
#66586 - 2002-06-10 10:34 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
#66588 - 2002-06-10 11:23 PM
Re: Round 2: KiXtart Golf Tournament Part III
|
BrianTX
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 239 anonymous users online.
|
|
|