Skip to content

Instantly share code, notes, and snippets.

@halirutan
Created April 30, 2017 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halirutan/bd37a41e37ff77aa9edb8bf233d9244a to your computer and use it in GitHub Desktop.
Save halirutan/bd37a41e37ff77aa9edb8bf233d9244a to your computer and use it in GitHub Desktop.
using BenchmarkTools
function canonical(t::Vector{Int64})
n = length(t)
sortcols(cat(2,
(circshift(t,x) for x=0:(n-1))...,
(circshift(reverse(t), x) for x=0:(n-1))...
)
)[:,1]
end
function deleteNecklaceDuplicates(list)
listCanonical = [(canonical(list[i,:]) for i=1:size(list,1))...]
unique(listCanonical)
end
largelist = rand(1:3,5000,15);
@benchmark deleteNecklaceDuplicates(largelist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment