-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolved.c
More file actions
53 lines (48 loc) · 1.48 KB
/
solved.c
File metadata and controls
53 lines (48 loc) · 1.48 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* solved.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mschroed <mschroed@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/04 14:17:28 by jgabelho #+# #+# */
/* Updated: 2019/01/06 19:12:25 by mschroed ### ########.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include "fillit.h"
#include <stdlib.h>
int recurse(t_mino *mino, t_map *mappie, int size)
{
int x;
int y;
if (mino == NULL)
return (1);
y = 0;
while (y < mappie->size)
{
x = 0;
while (x < mappie->size)
{
if (placer(mappie, mino, x, y))
{
if (recurse(mino->next, mappie, mappie->size))
return (1);
else
piece_reset(mappie, mino, x, y);
}
x++;
}
y++;
}
return (0);
}
int solved(t_mino *minos)
{
t_map *mappie;
mappie = map_new(2);
while (!recurse(minos, mappie, mappie->size))
mappie->size++;
printn2d(mappie->map, mappie->size);
return (1);
}