-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfriend_or_foe_main.cpp
More file actions
40 lines (35 loc) · 1.06 KB
/
Copy pathfriend_or_foe_main.cpp
File metadata and controls
40 lines (35 loc) · 1.06 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
/*
7 kyu
Friend or Foe?
https://www.codewars.com/kata/55b42574ff091733d900002f
*/
#include <iostream>
#include <string>
#include <vector>
std::vector<std::string> friendOrFoe(const std::vector<std::string>& input);
template <typename T>
static 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<std::string>& input,
const std::vector<std::string>& expected) {
std::vector<std::string> actual = friendOrFoe(input);
std::cout << "Input : " << input << std::endl;
std::cout << "Expected: " << expected << std::endl;
std::cout << "Actual : " << actual << std::endl;
std::cout << "-> " << (expected == actual ? "OK" : "FAIL") << std::endl
<< std::endl;
}
int main() {
do_test({"Ryan", "Kieran", "Jason", "Yous"}, {"Ryan", "Yous"});
do_test({"Eminem", "Pete", "Alan", "Jesus", "Homer Simpson"},
{"Pete", "Alan"});
return 0;
}