#ifndef CA_UWATERLOO_ALUMNI_DWHARDER_HAMMING_DISTANCE_STRING #define CA_UWATERLOO_ALUMNI_DWHARDER_HAMMING_DISTANCE_STRING #include namespace String_distances { namespace Hamming_distance { class String { public: static int distance( std::string const &s, std::string const &t ) { if ( s.length() > t.length() ) { return distance( t, s ); } int dist = 0; for ( int i = 0; i < s.length(); ++i ) { if ( s[i] != t[i] ) { ++dist; } } return dist + t.length() - s.length(); } }; } } #endif