-
-
Save anonymous/860bd9e367f895ed79a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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