-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
66 lines (59 loc) · 1.66 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yijhuang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/02 21:54:43 by yijhuang #+# #+# */
/* Updated: 2019/03/03 10:24:51 by xinzhang ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
t_flist *read_file_piece(char *fname)
{
t_flist *head;
head = NULL;
head = ft_read_piece(fname);
return (head);
}
int main_helper(char **board, t_flist *head, int size)
{
int reg;
reg = 0;
while (reg == 0)
{
board = ft_create_board(size);
reg = ft_backtracking(board, head, size);
if (reg == 1)
break ;
free_two_char(board);
size++;
}
free_list(head);
ft_print(board);
free_two_char(board);
return (1);
}
int main(int argc, char **argv)
{
char **board;
int pcs;
t_flist *head;
int reg;
int size;
if (argc == 1)
ft_usage();
else
{
reg = 0;
size = 0;
head = read_file_piece(argv[1]);
pcs = ft_get_list_length(head);
while (size * size < pcs * 4)
size++;
if (main_helper(board, head, size))
return (0);
return (0);
}
}