blob: f9651e0fef6a3f1e25cf2292d39d10d3a7aeaeeb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
#include <stdlib.h>
#include "hamming.h"
size_t compute(const char *lhs, const char *rhs) {
size_t diff = 0;
for (size_t idx = 0; ; idx++) {
short res = (lhs[idx] == '\0') + (rhs[idx] == '\0');
if (res == 1) return -1;
if (res == 2) return diff;
if (lhs[idx] != rhs[idx]) diff++;
}
}
|