Skip to content

Instantly share code, notes, and snippets.

@bryanaknight
Created December 1, 2013 20:16
Show Gist options
  • Save bryanaknight/7740114 to your computer and use it in GitHub Desktop.
Save bryanaknight/7740114 to your computer and use it in GitHub Desktop.
Hamming
class Hamming
def self.compute(sequence1, sequence2)
sequence1 = sequence1.split('')
sequence2 = sequence2.split('')
sequence1.zip(sequence2).count do |string_a, string_b|
self.substitution?(string_a, string_b)
end
end
def self.substitution?(string_a, string_b)
unless string_a == nil || string_b == nil
string_a != string_b
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment