-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_the_deadfish_swim_main.cpp
More file actions
39 lines (34 loc) · 941 Bytes
/
make_the_deadfish_swim_main.cpp
File metadata and controls
39 lines (34 loc) · 941 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
37
38
39
/*
6 kyu
Make the Deadfish Swim
https://www.codewars.com/kata/51e0007c1f9378fa810002a9
*/
#include <iostream>
#include <string_view>
#include <vector>
std::vector<int> parse(std::string_view data);
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::string_view& data,
const std::vector<int>& expected) {
std::vector<int> actual = parse(data);
std::cout << "Data : " << data << 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("iiisdoso", {8, 64});
do_test("iiisxxxdoso", {8, 64});
return 0;
}