Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'digest/sha1'
class String
def hash
Digest::SHA1.hexdigest self
end
def bit
"%0160b" % to_i(16)
end
end
def distance(word1, word2)
distance = 0
word1.chars.zip(word2.chars) do |char1, char2|
distance += 1 unless char1 == char2
end
return distance
end
test_phrase = "Rubinius one eight six active active record memcached exception JRuby DHH TOKYO sdfe3"
key_phrase = "I am not a big believer in fortune telling"
h1 = test_phrase.hash
h2 = key_phrase.hash
b1 = h1.bit
b2 = h2.bit
p distance b1, b2 # => 74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.