Created
April 30, 2017 13:38
-
-
Save halirutan/bd37a41e37ff77aa9edb8bf233d9244a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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