-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsame_arrays_main.cpp
More file actions
50 lines (44 loc) · 1.24 KB
/
same_arrays_main.cpp
File metadata and controls
50 lines (44 loc) · 1.24 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
/*
6 kyu
Are they the "same"?
https://www.codewars.com/kata/550498447451fbbd7600041c
*/
#include <iostream>
#include <vector>
using VI = std::vector<int>;
class Same {
public:
static bool comp(VI& a, VI& b);
};
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(VI a, VI b, bool expected) {
std::cout << "Array a : " << a << std::endl;
std::cout << "Array b : " << b << std::endl;
bool actual = Same::comp(a, b);
std::cout << "Expected: " << (expected ? "true" : "false")
<< ", actual: " << (actual ? "true" : "false") << " -> "
<< (expected == actual ? "OK" : "FAIL") << std::endl
<< std::endl;
}
int main() {
VI a = {121, 144, 19, 161, 19, 144, 19, 11};
VI b = {14641, 20736, 361, 25921, 361, 20736, 361, 121};
do_test(a, b, true);
a = {121, 144, 19, 161, 19, 144, 19, 11};
b = {14641, 20736, 361, 25921, 361, 20736, 362, 121};
do_test(a, b, false);
a = {-121, 1440, 191, 161, 19, 144, 195, 11};
b = {121, 14641, 2073600, 36481, 25921, 361, 20736, 38025};
do_test(a, b, true);
return 0;
}