Skip to content

Instantly share code, notes, and snippets.

@bmaland
Created September 22, 2008 19:54
Show Gist options
  • Save bmaland/12129 to your computer and use it in GitHub Desktop.
Save bmaland/12129 to your computer and use it in GitHub Desktop.
def hashing_necessary? numwords, hashkeys
numkeys = hashkeys.flatten.uniq.size
(numkeys < numwords) ? "rehash necessary" : "successful hashing"
end
puts hashing_necessary? 3, [[0, 1], [1, 2], [2, 0]]
puts hashing_necessary? 6, [[2, 3], [3, 1], [1, 2], [5, 1], [2, 5]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment