-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfillit.h
95 lines (77 loc) · 2.31 KB
/
fillit.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fillit.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: juazouz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/20 15:05:02 by juazouz #+# #+# */
/* Updated: 2018/11/29 13:55:23 by juazouz ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FILLIT_H
# define FILLIT_H
/*
** Includes.
*/
# include <stdlib.h>
# include <stdio.h>
# include <fcntl.h>
# include "libft.h"
/*
** Defines.
*/
# define BUFFER_SIZE 4096
# define TETRIMINOS_SIZE 4
# define INPUT_LINE_LEN 4
# define INPUT_LINE_COUNT TETRIMINOS_SIZE
# define INPUT_TETRIMINOS_SIZE 20
# define ERROR_MSG "error"
/*
** Types.
*/
typedef struct s_tetriminos t_tetriminos;
typedef struct s_point t_point;
typedef struct s_grid t_grid;
struct s_point
{
int x;
int y;
};
struct s_tetriminos
{
int id;
int height;
int width;
int points_count;
t_point points[TETRIMINOS_SIZE];
};
struct s_grid
{
int size;
t_tetriminos **cells;
};
/*
** Fillit functions.
*/
int input_parse(char *input,
t_tetriminos *tetri,
int count);
int tetriminos_validate(t_tetriminos *tetri);
void tetriminos_normalize(t_tetriminos *tetri);
t_grid *solve(t_tetriminos *tetri, int count);
int solve_core(t_grid *grid,
t_tetriminos *tetri,
int count,
int index);
t_grid *create_grid(int size);
void free_grid(t_grid *grid);
void print_grid(t_grid *grid);
t_tetriminos *cell_at(t_grid *grid, int x, int y);
void set_cell_at(t_grid *grid, int x, int y,
t_tetriminos *val);
int cells_count(t_grid *grid);
int distance(t_point *a, t_point *b);
int ft_abs(int n);
void *ft_safemalloc(size_t size);
#endif