Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created February 29, 2016 10:06
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 anonymous/860bd9e367f895ed79a0 to your computer and use it in GitHub Desktop.
Save anonymous/860bd9e367f895ed79a0 to your computer and use it in GitHub Desktop.
class Hamming
def self.compute(ancestor, descendant)
hamming = 0
if ancestor == descendant
0
end
elsif ancestor != descendant or ancestor == 0
raise ArgumentError, "Strings were of unequal length or empty"
end
else
ancestor.each do |amino_a|
descendant.each do |amino_b|
if amino_a != amino_b
hamming++
end
end
end
end
hamming
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment