-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_missing_letter_main.cpp
More file actions
36 lines (31 loc) · 889 Bytes
/
find_missing_letter_main.cpp
File metadata and controls
36 lines (31 loc) · 889 Bytes
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
/*
6 kyu
Find the missing letter
https://www.codewars.com/kata/5839edaa6754d6fec10000a2
*/
#include <iostream>
#include <vector>
char findMissingLetter(const std::vector<char>& chars);
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
os << "{";
for (size_t i = 0; i < v.size(); ++i) {
os << v[i];
if (i + 1 < v.size())
os << ", ";
}
os << "}";
return os;
}
static void do_test(const std::vector<char>& chars, const char expected) {
char actual = findMissingLetter(chars);
std::cout << "Array of letters: " << chars << std::endl
<< "Expected: \"" << expected << "\", actual: \"" << actual
<< "\" -> " << (expected == actual ? "OK" : "FAIL") << std::endl
<< std::endl;
}
int main() {
do_test({'a', 'b', 'c', 'd', 'f'}, 'e');
do_test({'O', 'Q', 'R', 'S'}, 'P');
return 0;
}