exercism/ruby/hamming/hamming.rb

8 lines
216 B
Ruby
Raw Normal View History

2018-09-21 09:30:10 -04:00
class Hamming
def self.compute(strand_one, strand_two)
raise ArgumentError unless strand_one.length == strand_two.length
2018-09-21 09:30:10 -04:00
0.upto(strand_one.length - 1).count {|i| strand_one[i] != strand_two[i] }
2018-09-21 09:30:10 -04:00
end
end