Created
November 23, 2017 14:34
-
-
Save jasiek/6992847e48551390e5a3c6093544c851 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
require 'securerandom' | |
N = 1_000_000 | |
M = 16 | |
s = Array.new(N) { SecureRandom.hex(M) } | |
s.sort! | |
def lcs(a, b) | |
M.times do |i| | |
return i if a[i] != b[i] | |
end | |
return M | |
end | |
buckets = Hash.new(1) | |
s.each_cons(2) do |a, b| | |
l = lcs(a, b) | |
buckets[l] += 1 | |
end | |
puts buckets.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment