Skip to content

Instantly share code, notes, and snippets.

@guilherme
Created October 29, 2016 06:44
Show Gist options
  • Save guilherme/96d1e41a1fcada6f006435672686e1b9 to your computer and use it in GitHub Desktop.
Save guilherme/96d1e41a1fcada6f006435672686e1b9 to your computer and use it in GitHub Desktop.
city hash "analysis"
require 'cityhash'
keywords = (0..4).to_a.inject(('a'..'z').to_a) do |perms, t|
perms = ('a'..'z').to_a.product(perms)
end.collect(&:join)
mod2_zero = 0
mod2_one = 0
keywords.each { |k| (CityHash.hash32(k) % 2) == 0 ? (mod2_zero += 1) : (mod2_one += 1) }
puts mod2_zero
puts mod2_one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment