Skip to content

Instantly share code, notes, and snippets.

@lkrych
Created November 3, 2016 15:17
Show Gist options
  • Save lkrych/c3dfc3285441f6b8e12567d6e7d3f7a2 to your computer and use it in GitHub Desktop.
Save lkrych/c3dfc3285441f6b8e12567d6e7d3f7a2 to your computer and use it in GitHub Desktop.
Almost the same as Hamming_improved_2.rb
class Hamming
def self.compute(s1,s2)
distance = 0
if s1.length != s2.length
raise ArgumentError
else
s1.chars.zip(s2.chars) {|s1char, s2char| distance += 1 unless s1char == s2char}
return distance
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment