Last active
May 13, 2016 04:02
-
-
Save gavinmcgimpsey/a20ddc8f7b985f2bdf02929076fa57fd 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 DNA | |
def initialize( str ) | |
@strand = str.chars | |
end | |
def hamming_distance( str ) | |
other_strand = str.chars | |
distance = 0 | |
@strand.each_with_index do | letter, i | | |
if other_strand[i] | |
distance += 1 if letter != other_strand[i] | |
end | |
end | |
distance | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment