Algorithm time...
Dick Kriesel
dick.kriesel at mail.com
Sun Dec 9 05:26:12 EST 2012
On Dec 9, 2012, at 12:33 AM, Glen Bojsza wrote:
> I believe that this should be doable less than 1 second
Hi, Glen. Here's a draft you could try. It works for the sample data you posted.
If you have questions, please ask. If you try it, please report your timings.
-- Dick
<postScript>
function foo @pLines
put the number of lines in pLines div 1000 into tGroupSize
set the itemDelimiter to tab
repeat for each line tLine in pLines
add 1 to tLineNumber
put item 2 of tLine into tValue
if tIndex[ tValue ] is empty then
put tLineNumber into tIndex[ tValue ]
end if
if tLineNumber is tGroupSize then
put the keys of tIndex into tValues
replace cr with comma in tValues
put min( tValues ) into tMin
put max( tValues ) into tMax
if tIndex[ tMin ] < tIndex[ tMax ] then
put tIndex[ tMin ] & tab & tMin & cr after tResult
put tIndex[ tMax ] & tab & tMax & cr after tResult
else
put tIndex[ tMax ] & tab & tMax & cr after tResult
put tIndex[ tMin ] & tab & tMin & cr after tResult
end if
put empty into tIndex
put 0 into tLineNumber
end if
end repeat
return tResult
end foo
</postScript>
More information about the use-livecode
mailing list