Skip to content

Instantly share code, notes, and snippets.

@alandipert
Forked from kdaigle/gist:151159
Created July 21, 2009 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alandipert/151162 to your computer and use it in GitHub Desktop.
Save alandipert/151162 to your computer and use it in GitHub Desktop.
def bit
"%0160b" % to_i(16)
end
def distance(word1, word2)
word1, word2 = word1.bit, word2.bit
distance = 0
word1.chars.zip(word2.chars) do |char1, char2|
puts "#{char1} | #{char2}"
distance += 1 unless char1 == char2
end
return distance
end
word1 = Digest::SHA1.hexdigest("challenge")
word2 = Digest::SHA1.hexdigest("entry")
distance(word1,word2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment