-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_block.c
41 lines (38 loc) · 1.42 KB
/
check_block.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_block.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akerkeb <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/21 23:10:37 by akerkeb #+# #+# */
/* Updated: 2016/01/21 23:40:26 by akerkeb ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
int ft_check_block(char *str)
{
int y;
int count_ch;
int count_diez;
int t;
t = 0;
y = -1;
count_ch = 0;
count_diez = 0;
while (str[++y])
{
if ((y == 9 || y == 14 || y == 19) && str[y - 5] != '\n')
return (0);
else if (str[y] == '#' && (str[y - 1] == '#' || str[y + 1] == '#' ||
str[y + 5] == '#' || str[y - 5] == '#'))
count_diez++;
if (str[y] == '#' && ft_check_block_plus(str, y) && !t--)
count_diez++;
if (str[y] == '.')
count_ch++;
}
if (count_ch == 12 && count_diez == 5)
return (1);
return (0);
}