Skip to content

Instantly share code, notes, and snippets.

@guilherme
Created October 29, 2016 06:44
Show Gist options
  • Select an option

  • Save guilherme/96d1e41a1fcada6f006435672686e1b9 to your computer and use it in GitHub Desktop.

Select an option

Save guilherme/96d1e41a1fcada6f006435672686e1b9 to your computer and use it in GitHub Desktop.

Revisions

  1. guilherme created this gist Oct 29, 2016.
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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