-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_valid.c
61 lines (56 loc) · 1.85 KB
/
all_valid.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fillit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vmiachko <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/13 16:29:46 by vmiachko #+# #+# */
/* Updated: 2017/12/27 15:54:56 by npiriyev ### ########.fr */
/* */
/* ************************************************************************** */
#include "terminos.h"
#include "validation.h"
#include "read_and_alloc.h"
#include "all_valid.h"
#include "validation.h"
int all_valid(char **argv, int *num_term, char ****res)
{
int i;
t_coord s;
char buf[546];
int counter;
i = -1;
read_file(argv, buf);
if (first_check(0, num_term, buf))
{
*res = create_array(*num_term);
fill_array(*res, *num_term, buf);
while (++i < *num_term)
{
s.x = 0;
s.y = 0;
find_first_hash(&s.y, &s.x, i, *res);
counter = 0;
if (!check_position(s, i, *res, &counter))
return (0);
}
}
else
return (0);
return (1);
}
int my_exception(t_coord s, char ***res, int t)
{
t_coord s1;
s1.x = 0;
s1.y = 0;
find_first_hash2(&s1.y, &s1.x, t, res);
if (res[t][s1.x][s1.y + 1] == '#' && res[t][s1.x][s1.y + 2] == '#' &&
s1.x != s.x && s1.y != s.y)
return (1);
else if (s1.y < 3 && res[t][s1.x][s1.y + 1] == '#' && s1.x < 3 &&
res[t][s1.x + 1][s1.y] == '#' && s1.x != s.x && s.y != s1.y)
return (1);
return (0);
}