-
Notifications
You must be signed in to change notification settings - Fork 0
/
AreSame.cpp
63 lines (52 loc) · 1.53 KB
/
AreSame.cpp
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
56
57
58
59
60
61
62
63
\\ https://www.codewars.com/kata/550498447451fbbd7600041c/train/cpp
#include <iostream>
using namespace std;
class Same {
public :static bool comp(vector<int> a1, vector<int> b1)
{
bool rcB = true;
int a2;
std::vector<int>::reverse_iterator ritb;
cout << "------- start " << a1.size() << endl;
cout << "------- start " << b1.size() << endl;
if (a1.size() != b1.size())
{
rcB = false;
return rcB;
}
for (auto rita = a1.crbegin(); rita != a1.crend(); ++rita)
{
a2 = (*rita)*(*rita);
rcB = false;
cout << "---rita " << *rita << endl;
cout << "a2 " << a2 << endl;
for (ritb = b1.rbegin(); ritb != b1.rend(); ++ritb)
{
cout << "ritb " << *ritb << endl;
if (*ritb == a2)
{
rcB = true;
*ritb = -1;
break;
}
}
if (!rcB)
{
break;
}
}
return rcB;
};
};
Describe(SameTest)
{
It(test1)
{
static const int arr1[] = {121, 144, 19, 161, 19, 144, 19, 11};
vector<int> a1 (arr1, arr1 + sizeof(arr1) / sizeof(arr1[0]));
static const int arr2[] = {11*11, 121*121, 144*144, 19*19, 161*161, 19*19, 144*144, 19*19};
vector<int> b2 (arr2, arr2 + sizeof(arr2) / sizeof(arr2[0]));
bool r = Same::comp(a1, b2); // true
Assert::That(r, Equals(true));
}
};