Skip to content

Instantly share code, notes, and snippets.

@michellejanosi
Created June 2, 2017 18:55
Show Gist options
  • Select an option

  • Save michellejanosi/2b3e158346766edc4f6fc5cc1e2cba23 to your computer and use it in GitHub Desktop.

Select an option

Save michellejanosi/2b3e158346766edc4f6fc5cc1e2cba23 to your computer and use it in GitHub Desktop.
Hamming in Ruby
class Hamming
def self.compute(a, b)
raise ArgumentError if a.length != b.length
counter = 0
a.split('').each_with_index do |item, index|
if a[index] != b[index]
counter += 1
end
end
counter
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment