Here is mine. I wanted to try recursion but I later discovered it is almost impossible to get a low score if you have to call a second function. I realized a couple of days ago that this solution was not a winner. In theory this function should give the optimal results all the time because it is really a variant of the Brute Force technique. Pruning the binary trees when they become negative can optimize it further but this adds strokes. Pre-sorting would also improve efficiency. Converting all values to integer would improve efficiency further & eliminate floating point problems. While, I have been too busy too validate this with Jens' script, I am sure it will pass but it is really slow!

code:
Function CDSorter($, $G)
$=split($,",")
$G=0.+$G,""
$=P($,ubound($)+1,$G)
$CDSorter=substr($[1],2)
Endfunction
Function P($S,$I,$)
If $I ;If $I and $[0]>=0 is more efficient
$P=P($S,$I-1,$)
$=$[0]-$S[$I-1],$[1]+","+$I
$=P($S,$I-1,$)
$=IIF($P[0]<$[0],IIF($P[0]<0,$,$P),IIF($[0]<0,$P,$))
Endif
$P=$
Endfunction

Score=275
Revised Score=253

When using this script I ran into several problems. First, it doesn't generate optimal results consistently. I manually checked some of the results & Richard's brute force tecgnique gives correct results consistently but this one doesn't. The difference between the methods is small but they exist. Why this occurring, I am not certain. I tried putting the CDbl function around every subcomponent used in the gap calculation but this did not eliminate the problem. My best guess, is that when kixtart passes arrays back & forth through the function call, it must do some internal data conversion based upon what values are actually in the array not what I declare them to be. Also, the problem seems to be in the returning array not in the passed down array.

The second problem occurs because I can not get this script to shutdown. When, I try to use the Task Manager in my Win2000 OS to shut it down, my OS crashes. This is the first time, I have ever crashed Win2000.

Richard,

I see you & I were thinking along similar lines. I thought of using global variables but I thought that was sort of cheating because in my mind that is not truly an UDF. So I used your trick of passing arrays up & down instead.

Also, Richard after seeing your script, I think that I see why my script is not working consistently. This might be the same problem we ran into in an earlier kixgolf competition which indicated Kixtart arithmatic didn't function well when "if testing" 2 floating point numbers that are very close together. Kixtart hates floatng point! Greer! [Mad] [Mad]

[ 18. March 2003, 20:32: Message edited by: Jack Lothian ]
_________________________
Jack