-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_1_4.c
165 lines (153 loc) · 3.28 KB
/
check_1_4.c
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_1_4.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpetrosy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/13 01:31:36 by dpetrosy #+# #+# */
/* Updated: 2022/02/13 23:05:41 by dpetrosy ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
void check_1(int solved[][5], int nums[][6], int matrix[][5][5]);
void check_4_u_d(int solved[][5], int nums[][6], int matrix[][5][5]);
void clear_nums(int matrix[][5][5], int i, int j, int num);
void check_1_r_l(int solved[][5], int nums[][6], int matrix[][5][5]);
void check_4_r_l(int solved[][5], int nums[][6], int matrix[][5][5]);
void check_4_tricks(int solved[][5], int nums[][6], int matrix[][5][5]);
void check_3(int solved[][5], int nums[][6], int matrix[][5][5]);
void check_3_tricks(int nums[][6], int matrix[][5][5]);
void check_1_4(int solved[][5], int nums[][6], int matrix[][5][5])
{
int i;
int j;
i = 0;
while (i <= 4)
{
j = 0;
while (j <= 4)
{
solved[i][j] = 0;
++j;
}
++i;
}
check_1(solved, nums, matrix);
check_1_r_l(solved, nums, matrix);
check_4_u_d(solved, nums, matrix);
check_4_r_l(solved, nums, matrix);
check_4_tricks(solved, nums, matrix);
check_3(solved, nums, matrix);
check_3_tricks(nums, matrix);
}
void check_1(int solved[][5], int nums[][6], int matrix[][5][5])
{
int j;
j = 0;
while (++j <= 4)
{
if (nums[0][j] == 1)
{
solved[1][j] = 4;
clear_nums(matrix, 1, j, 4);
}
}
j = 0;
while (++j <= 4)
{
if (nums[5][j] == 1)
{
solved[4][j] = 4;
clear_nums(matrix, 4, j, 4);
}
}
}
void check_1_r_l(int solved[][5], int nums[][6], int matrix[][5][5])
{
int i;
i = 0;
while (++i <= 4)
{
if (nums[i][0] == 1)
{
solved[i][1] = 4;
clear_nums(matrix, i, 1, 4);
}
}
i = 0;
while (++i <= 4)
{
if (nums[i][5] == 1)
{
solved[i][4] = 4;
clear_nums(matrix, i, 4, 4);
}
}
}
void check_4_u_d(int solved[][5], int nums[][6], int matrix[][5][5])
{
int i;
int j;
int k;
j = 0;
while (++j <= 4)
{
i = 0;
if (nums[0][j] == 4)
{
while (++i <= 4)
{
solved[i][j] = i;
clear_nums(matrix, i, j, i);
}
}
}
j = 0;
while (++j <= 4)
{
i = 0;
k = 4;
if (nums[5][j] == 4)
{
while (++i <= 4)
{
solved[k][j] = i;
clear_nums(matrix, k--, j, i);
}
}
}
}
void check_4_r_l(int solved[][5], int nums[][6], int matrix[][5][5])
{
int i;
int j;
int k;
i = 0;
while (++i <= 4)
{
j = 0;
if (nums[i][0] == 4)
{
while (++j <= 4)
{
solved[i][j] = j;
clear_nums(matrix, i, j, j);
}
}
}
i = 0;
while (++i <= 4)
{
j = 0;
k = 4;
if (nums[i][5] == 4)
{
while (++j <= 4)
{
solved[i][k] = j;
clear_nums(matrix, i, k--, j);
}
}
}
}