-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_no_island.c
41 lines (38 loc) · 1.35 KB
/
ft_no_island.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_no_island.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jtrujill <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/17 21:37:38 by jtrujill #+# #+# */
/* Updated: 2016/12/17 21:43:11 by jtrujill ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
int ft_no_island(const char *str)
{
int i;
int j;
i = 0;
j = 0;
while (str[i] != '\0')
{
if (str[i] == '#')
{
if ((str[i + 1] == '#') || (str[i + 5] == '#'))
j++;
else if ((str[i - 1] == '#') && (str[i + 4] == '#'))
j++;
else if (((str[i - 5] == '#') || (str[i - 1] == '#')) && (j == 3))
j++;
else if ((str[i - 1] == '#') && (str[i + 3] == '#') && (j == 2))
j++;
}
i++;
}
if (j == 4)
return (1);
else
return (0);
}