Guest User

Untitled

a guest
Nov 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. require 'securerandom'
  2.  
  3. N = 1_000_000
  4. M = 16
  5.  
  6. s = Array.new(N) { SecureRandom.hex(M) }
  7. s.sort!
  8.  
  9. def lcs(a, b)
  10. M.times do |i|
  11. return i if a[i] != b[i]
  12. end
  13. return M
  14. end
  15.  
  16. buckets = Hash.new(1)
  17.  
  18. s.each_cons(2) do |a, b|
  19. l = lcs(a, b)
  20. buckets[l] += 1
  21. end
  22.  
  23. puts buckets.inspect
Add Comment
Please, Sign In to add comment