Created
November 3, 2016 12:45
-
-
Save lkrych/2bccbfb1b2a9edd8225f89657fa3dcf6 to your computer and use it in GitHub Desktop.
Naive implementation of Hamming distance for exercism.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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