19 |
***************************************************************************/ |
***************************************************************************/ |
20 |
#include "solution.h" |
#include "solution.h" |
21 |
|
|
|
|
|
22 |
Solution::Solution(int size) |
Solution::Solution(int size) |
23 |
{ |
{ |
24 |
m_size = size; |
m_size = size; |
25 |
for (int i=0; i<m_size; i++) |
|
26 |
for (int j=0; j<m_size; j++) |
for (int i=0; i<size; i++) |
27 |
m_matrix[i][j] = false; |
{ |
28 |
|
m_matrix[i] = -1; |
29 |
|
} |
30 |
} |
} |
31 |
|
|
32 |
|
|
34 |
{ |
{ |
35 |
} |
} |
36 |
|
|
37 |
|
Solution::Solution(const Solution& input) |
|
Solution::Solution(const Solution &input) |
|
38 |
{ |
{ |
39 |
m_size = input.m_size; |
m_size = input.m_size; |
40 |
for (int i=0; i<m_size; i++) |
for (int i=0; i<m_size; i++) |
41 |
for (int j=0; j<m_size; j++) |
m_matrix[i] = input.m_matrix[i]; |
|
m_matrix[i][j] = input.m_matrix[i][j]; |
|
42 |
} |
} |
43 |
|
|
44 |
|
/* |
45 |
void Solution::set(bool input[MAX_SIZE][MAX_SIZE]) |
void Solution::set(unsigned char input[MAX_SIZE]) |
46 |
{ |
{ |
47 |
for (int i=0; i<m_size; i++) |
for (int i=0; i<m_size; i++) |
48 |
for (int j=0; j<m_size; j++) |
m_matrix[i] = input[i]; |
49 |
m_matrix[i][j] = input[i][j]; |
}*/ |
|
} |
|
50 |
|
|
51 |
|
/* |
52 |
void Solution::rotate90() |
inline bool Solution::getMatrix(int x, int y) |
53 |
{ |
{ |
54 |
bool temp[MAX_SIZE][MAX_SIZE]; |
return (m_matrix[x] == y); |
55 |
|
}*/ |
56 |
|
/* |
57 |
|
void Solution::setMatrix(int x, int y, bool val) |
58 |
|
{ |
59 |
|
if (val == true) |
60 |
|
m_matrix[x] = y; |
61 |
|
else |
62 |
|
m_matrix[x] = -1; |
63 |
|
}*/ |
64 |
|
/* |
65 |
|
bool Solution::operator ==(const Solution& s) |
66 |
|
{ |
67 |
|
const Solution& sol = dynamic_cast<const Solution&>(s); |
68 |
for (int i=0; i<m_size; i++) |
for (int i=0; i<m_size; i++) |
69 |
for (int j=0; j<m_size; j++) { |
if (m_matrix[i] != sol.m_matrix[i]) |
70 |
temp[j][(m_size-1)-i] = m_matrix[i][j]; |
return false; |
71 |
} |
return true; |
72 |
set(temp); |
}*/ |
|
} |
|
73 |
|
|
74 |
void Solution::mirror() |
Solution* Solution::copy() |
75 |
{ |
{ |
76 |
bool temp[MAX_SIZE][MAX_SIZE]; |
return new Solution(*this); |
|
|
|
|
for (int i=0; i<m_size; i++) |
|
|
for (int j=0; j<m_size;j++) |
|
|
temp[i][(m_size-1)-j] = m_matrix[i][j]; |
|
|
set(temp); |
|
77 |
} |
} |
78 |
|
|
79 |
|
/* |
80 |
bool Solution::operator==(const Solution& sol) |
void Solution::mirror() |
81 |
{ |
{ |
82 |
|
unsigned char temp[MAX_SIZE]; |
83 |
for (int i=0; i<m_size; i++) |
for (int i=0; i<m_size; i++) |
84 |
for (int j=0; j<m_size; j++) |
temp[i] = (m_size-1) - m_matrix[i]; |
85 |
if (m_matrix[i][j] != sol.m_matrix[i][j]) |
set( temp ); |
86 |
return false; |
}*/ |
|
return true; |
|
|
} |
|
87 |
|
|
88 |
bool Solution::operator!=(const Solution& sol) |
/* |
89 |
|
void Solution::rotate90() |
90 |
{ |
{ |
91 |
int matchcount = 0; |
unsigned char temp[MAX_SIZE]; |
92 |
|
|
93 |
for (int i=0; i<m_size; i++) |
for (int i=0; i<m_size; i++) |
94 |
for (int j=0; j<m_size; j++) |
{ |
95 |
if (m_matrix[i][j] == sol.m_matrix[i][j]) |
int x = i; |
96 |
matchcount++; |
int y = m_matrix[i]; |
97 |
if (matchcount == (m_size*2) ) |
|
98 |
return false; |
temp[y] = (m_size-1) - x; |
99 |
else |
} |
100 |
return true; |
|
101 |
} |
set( temp); |
102 |
|
}*/ |
103 |
|
|
|
bool Solution::getMatrix(int x, int y) { |
|
|
return m_matrix[x][y]; |
|
|
} |
|
|
|
|
|
void Solution::setMatrix(int x, int y, bool val) { |
|
|
m_matrix[x][y] = val; |
|
|
} |
|
|
|
|
|
|
|
|
Solution* Solution::copy() |
|
|
{ |
|
|
return new Solution(*this); |
|
|
} |
|