Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/7a69d7a8a224629c6c459a2665df92de to your computer and use it in GitHub Desktop.
Save trycf/7a69d7a8a224629c6c459a2665df92de to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
function calc( a, k ){
s = getTickCount();
dump(a);
st = {};
for (var aa in a){
if (!structKeyExists(st, aa))
st[aa] = 0;
st[aa]++;
}
dump(st);
b = structSort(st, "numeric", "asc")
dump(b);
c = arraySlice(b, k+1);
echo(len(c) & " unique values<br>");
echo(getTickCount()-s & "<hr>")
}
calc ([5,5,4], 1);
calc ([4,4,5], 1);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment