2010-07-13 20:15:08 +00:00
|
|
|
#include "jellyfish.h"
|
2010-07-11 03:39:24 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2010-07-12 20:42:56 +00:00
|
|
|
size_t hamming_distance(const char *s1, const char *s2) {
|
2010-07-11 03:39:24 +00:00
|
|
|
unsigned distance = 0;
|
|
|
|
|
2010-07-12 20:42:56 +00:00
|
|
|
for (; *s1 && *s2; s1++, s2++) {
|
|
|
|
if (*s1 != *s2) {
|
|
|
|
distance++;
|
2010-07-11 03:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( ; *s1; s1++) {
|
|
|
|
distance++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( ; *s2; s2++) {
|
|
|
|
distance++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return distance;
|
|
|
|
}
|