Repository navigation
Expand file tree
/
Copy pathlib.h
More file actions
182 lines (143 loc) · 4.29 KB
/
Copy pathlib.h
File metadata and controls
182 lines (143 loc) · 4.29 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lib.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agabasov <agabasov@student.42lausanne +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/24 17:21:43 by agabasov #+# #+# */
/* Updated: 2023/06/24 18:47:27 by sgiazzi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIB_H
# define LIB_H
# include <assert.h>
# include <errno.h>
# include <fcntl.h>
# include <stdbool.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <unistd.h>
/*
|----------------|---|......
|....o...........|...|......
|........A...o...|.B.|......
|----------------a---b......
|....o...........|...|......
|........C......o|.D.|......
|................|...|......
|------o---------c---do.....
..o.......o................
|----------------|---|......
|....o...A.......|.B.|......
|------------o---a---b......
|................|...|......
|....o...........|...|......
|........C......o|.D.|......
|................|...|......
|------o---------c---do.....
..o.......o................
a.x = c.x | b.x = d.x
|-------------|----|---
| | | |
| | | |
|_____________a____b | a.y = b.y
| | | |
| | | |
|_____________c____d | d.y = c.y
|_____________________|
d.x = b.x
-----------------------
| | |
| | |
|_____________b | b.y
| | |
| | |
|_____________d | d.y
|_____________________|
c.x d.x
-----------------------
| | | |
| | | |
|_____________c____d | d.y = c.y
| |
| |
| |
|_____________________|
d.x
-----------------------
| | |
|----d |
| |
| | d.y
| |
| |
|_____________________|
*/
typedef struct s_point
{
int x;
int y;
} t_point;
typedef struct s_specification
{
bool valid;
char emp;
char obs;
char full;
int n;
int len;
} t_map_spec;
typedef struct s_map
{
bool valid;
t_map_spec spec;
char **str;
} t_map;
typedef struct s_solution
{
int size;
t_point d;
} t_solution;
typedef struct s_solver_spec
{
t_point a;
t_point b;
t_point c;
t_point d;
} t_solver_spec;
size_t ft_strlen(const char *str);
void ft_putchar(char c);
void ft_putstr(const char *str);
void ft_putnbr_aux(int n);
void ft_putnbr(int nb);
void ft_puterr(char *error_detail);
int ft_ctoi(char c);
size_t ft_get_fsize(int fd);
bool ft_check_read(int fd);
bool ft_check_open(int fd);
char *ft_get_file(int fd, size_t file_size);
void *ft_memcpy(void *dst0, const void *src0, size_t size);
void ft_get_map_obstacle_count(t_map map);
void ft_putsize(size_t size);
int ft_get_best_size(int **arr, t_point d);
int ft_get_obstacles(int **arr, t_solver_spec spec);
int ft_get_size(t_solver_spec solver_spec);
// Switch int to char in ASCII (+ 48)
char ft_stoc(size_t size);
int ft_power(int b, unsigned int e);
t_map_spec ft_make_spec(char *map_string);
void ft_show_spec(t_map_spec specification);
char *ft_get_stdin_string(void);
void ft_print_map(t_map map);
void ft_preset_obstacles(int **obstacle_matrix, t_map map);
void ft_set_all_obstacle_count(t_map map, int **obstacle_matrix);
t_solution ft_get_best_solution(int **arr, t_map map);
void ft_show_solution(t_solution solution, t_map map);
char *ft_strchr(char *str, char c);
t_map ft_make_map(char *map_string);
void map_solve(char *map_string);
char *ft_stdin_str_aux(size_t file_size, ssize_t last_read,
char **map_string);
#endif