So, here are the updated rules for Kixtart Golf:================================================================KiXtart GOLF - The rules================================================================

The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.

Example: How many positive elements are in array $a?

Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9].

One approach:

code:

for $b=0 to ubound($a) if $a[$b]>0 $c=$c+1 endifnext

for a score of 45.

Another solution is:

code:

DO $b=$b+1 if $a[$b]>0 $c=$c+1 endifUNTIL $b>(UBOUND($a)+1)

for a score of 53.

Better approach: Code sample 1

How is it scored?-----------------Every kystroke will be counted. There is no penalty for obscurity or execution time. UDFs are allowed and will be counted as hits, too. The carriage return character and the space character used to separate commands/functions do not count as strokes.

All public releases of KiXtart are allowed up to and including KiXtart 4.10 RC2.

Within the first 48 hours or until the time set by the KiXtart Golf organizer, no code can be posted. People who post code will be disqualified. The only thing to be posted within this period is the KiXtart Golf score and the answer to the challange question (if an answer is to be provided).

After this initial period, everybody is allowed to post code and modify other poeple's code, too for another 48 hours. So, somebody is allowed/encouraged to take a posted solution with for example a KiXtart Golf score of 100 and optimize this code to score only 99.

There are a total of three winners based on this approach:Winner 1) The first person posting the solution to the question (if applicable)Winner 2) The person with the lowest KiXtart Golf score within the first 48 hour period (first round)Winner 3) The person with the lowest KiXtart Golf score within the second 48 hour period (second round)

The first round will go from Saturday, June 8, time of postiong to Monday, June 10, 3pm Eastern Standard Time (EST, GMT-6)The second round will go from Monday, June 10, 3pm EST to Wednesday, June 12, 3pm EST

This will give contestants in all time zones enough time to come up with potential solutions.

=====================================================And now the challange for KiXtart Golf Tournament III=====================================================

Write a generic base converter for bases 2-36. BASE10 is the decimal system, BASE2 is the binary system, BASE16 is the hexadecimal system, extensions beyond BASE16 are accomplished by filling up with letters from the English alphabet, so BASE17 would consist of the following values 0123456789ABCDEFG. BASE36 is a special case as it consist of all numbers 0-9 and all letters A-Z. Therefore, all english words can be converted into a BASE10 representation.

Example: (ADD)36 = (10·362 + 13·36 + 13)10 = (13.441)10

The structure for the UDF that is to be created is

$result=BaseConverter($value,$frombase,$tobase)

and I want to know the answer for

$result=BaseConverter('44680832201','10','36')

and the KiXtart Golf score.

Hint: There are two different approaches, one iterative approach and one recursive approach.

[ 08 June 2002, 16:45: Message edited by: sealeopard ]

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

Are you sure you couldn't have made this one any tougher Jens ? And it had to be math too And the number conversion your asking for is bigger than what Kixtart supports - oi ! Nice puzzle, should keep us a busy for while ...

Shawn: Yeah, the math is definitely interesting but I also gave two ways to solve the problem.

And with regards to the number conversion, if I understand the manual for KiXtart 4.10RC2 correctly, then this number should still be within the range of numbers that KiXtart can handle. If this is not the case, I will give it a try, then I will downsize the number to make it still doable.

Nevertheless, the routine itself is definitely doable in Kixtart. Also, I gave 48 hours time, so you don't have to work during the weekend but can attack the problem during the slow hours at work.

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

Think I got some of the bits and pieces, but I can't get my mind around to put them all together, definitely won't be posting a score anytime soon, but i did figure out the answer (sure others have by now too) very clever.

Howard, how you making out there buddy ? Les - whazzup ? Im a little uncertain about a couple of things ... think we made need some further clarification - the big numbers are causing me grief ... plus, how big of a number must we support ? And the other thing is about negative numbers ... arrggghhh ! mother ! jack !

When I'm talking slow, i'm meaning SLOW!!!! Just processing the test code will take a few hours.. shorter pieces (3 or 4 characters base 36) take less. Instead of messing around with large numbers, I'm using an incremental method.

I have two sets of code. The first will not handle numbers larger than KiXtart integers... (and runs faster)

The second will handle anything, but runs VERY SLOWLY.

For the slow one (that handles larger numbers) my score is 375.

For the faster one, my score is 243. however it won't do the sample one because the numbers are too large.

If I need to make (the second method) so that it will work for even the huge numbers, I will have to write my own MOD and division functions.

{EDIT} After much thinking about this (and testing some), I believe that adding complexity to my long-running script would indeed speed it up quite a bit, but at the cost of score.. I'm using the "cave-man" approach, but it works. I've estimated that a 7 character base 36 number could take up to 125 days (ouch!) to convert to base 10. A 5 character base 36 number could be converted in about 2 hours.

So, are you guys are measuring the amount of code including your function/endfunction statements ? or just between these statements ? or the whole kit-and-kabootle, including the test call to the function ?

I'm a little handicapped right now since my home computer is still pretty much dead, at least I got my Windows 98 partition working again to be able to surf the web and find solutions why the Win2K box logs me out right after accepting my login.

Anyway, I did do some testing on KiXtart 4.10RC2 before writing the challange and Kixtart seems to be able to handle large numbers if you convert to the CDBL() format of the number, which according to the manual is a double (= 8-byte double floating point, if I remember my C++ days correctly). Now, if the MOD() function indeed does not handle a large number, then a) we found a bug in KiXtart 4.10RC2 and b) there is a generic MOD() UDF on this board.

With regards to scoring the script, everything from $a=FUNCTION($b,$c,$d) up to and including ENDFUNCTION counts (except, of cource the comments, extraneous spaces and carriage return/linefeed characters).

I also believe that we will need a special assignment for Howard since he's beating everybody again. But, on the other hand, once he's posting his code on Monday afternoon EST, we can take it apart and see whether we can find ways for improvement.