-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_functions.c
60 lines (55 loc) · 1.75 KB
/
check_functions.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_functions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: conguyen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/23 23:24:29 by qnguyen #+# #+# */
/* Updated: 2022/02/24 15:45:09 by conguyen ### ########.fr */
/* */
/* ************************************************************************** */
#include "wordle.h"
int check_gsy(char *possible_word, char *input_word, char *color)
{
int i;
int i2;
int present;
i = 0;
while (input_word[i])
{
if (color[i] == 'g')
if ((possible_word[i] != input_word[i]))
return (0);
i2 = 0;
present = 0;
while (possible_word[i2])
{
if (color[i] == 's')
if (possible_word[i2] == input_word[i] && color[i2] != 'g')
return (0);
if (color[i] == 'y')
if (possible_word[i2] == input_word[i] && i != i2)
present = 1;
i2++;
}
if (present == 0 && color[i] == 'y')
return (0);
i++;
}
return (1);
}
void check_word(char w_list[TOTAL_WORDS + 1][6], char after_list[TOTAL_WORDS + 1][6], char *word, char *color)
{
int i;
int i2;
i = 0;
i2 = 0;
while (w_list[i][0] != '\0')
{
if (check_gsy(w_list[i], word, color))
ft_strcpy(after_list[i2++], w_list[i]);
i++;
}
after_list[i2][0] = '\0';
}