Skip to content

Instantly share code, notes, and snippets.

@lkrych
Created November 3, 2016 12:45
Show Gist options
  • Save lkrych/2bccbfb1b2a9edd8225f89657fa3dcf6 to your computer and use it in GitHub Desktop.
Save lkrych/2bccbfb1b2a9edd8225f89657fa3dcf6 to your computer and use it in GitHub Desktop.
Naive implementation of Hamming distance for exercism.io
class Hamming
def self.compute(s1,s2)
if s1.length != s2.length
raise ArgumentError
else
index = 0
count = 0
while index < (s1.length)
if s1[index] != s2[index]
count += 1
end
index += 1
end
return count
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment