-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHammingDistance.cpp
More file actions
55 lines (50 loc) · 1.13 KB
/
HammingDistance.cpp
File metadata and controls
55 lines (50 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include <string>
#include <sstream>
#include <climits>
#include<iomanip>
using namespace std;
unsigned hamming(const string& a, const string& b) {
unsigned result = 0;
for (int i = 0; i < a.size(); i++)
{
if (a[i] != b[i])
{
result++;
}
}
return result;
}
int main()
{
cout << hamming("", "");
return 0;
}
/*Description:
The Hamming Distance is a measure of similarity between two strings of equal length.
Complete the function so that it returns the number of positions where the input strings do not match.
Examples:
a = "I like turtles"
b = "I like turkeys"
Result: 3
a = "Hello World"
b = "Hello World"
Result: 0
a = "espresso"
b = "Expresso"
Result: 2
You can assume that the two inputs are ASCII strings of equal length.
Algorithms*/
// /> フ
// | n n 彡
// /`ミ_xノ
// / |
// / ヽ ノ
// │ | | |
// / ̄| | | |
// | ( ̄ヽ__ヽ_)__)
// \二つ
// ITS CAT FOR YOU