Created
May 14, 2024 03:53
-
-
Save DrunkenAlcoholic/04472aa53b59f04de2cb633042bd479f to your computer and use it in GitHub Desktop.
Hamming [Exercism - Nim]
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
proc distance*(a, b: string): int = | |
if a.len != b.len: | |
raise (ref ValueError)(msg: "out of bounds") | |
else: | |
for i in low(a)..high(a): | |
if a[i] != b[i]: inc(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment