exercism/ruby/hamming/hamming.rb

16 lines
236 B
Ruby
Raw Normal View History

2018-09-21 09:30:10 -04:00
class Hamming
def self.compute(a, b)
if a.length != b.length
raise ArgumentError
end
distance = 0
0.upto(a.length - 1) do |i|
if a[i] != b[i]
distance += 1
end
end
distance
end
end