Skip to content

Instantly share code, notes, and snippets.

@gavinmcgimpsey
Last active May 13, 2016 04:02
Show Gist options
  • Save gavinmcgimpsey/a20ddc8f7b985f2bdf02929076fa57fd to your computer and use it in GitHub Desktop.
Save gavinmcgimpsey/a20ddc8f7b985f2bdf02929076fa57fd to your computer and use it in GitHub Desktop.
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