hamming.rb

1
2
3
4
5
6
7
8
class Hamming
  VERSION = 1
  def self.compute(strand1, strand2)
    s1, s2 = strand1.chars, strand2.chars
    raise ArgumentError unless s1.length == s2.length
    s1.zip(s2).count { |x, y| x != y }
  end
end

Comments


You're not logged in right now. Please login via GitHub to comment