This commit is contained in:
David Gailleton
2025-12-16 10:25:17 +01:00
parent aac8832df3
commit 63bb1bc416
5 changed files with 360 additions and 0 deletions

27
04_b/aoc04_b.h Normal file
View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aoc04_b.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/15 16:15:37 by dgaillet #+# #+# */
/* Updated: 2025/12/15 16:33:20 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef AOC04_B_H
# define AOC04_B_H
typedef struct s_co
{
int i;
int j;
void *next;
} t_co;
t_co *new_co(int i, int j);
void co_add_back(t_co **lst, t_co *new);
void clear_lst(t_co *lst);
#endif

10
04_b/example Normal file
View File

@@ -0,0 +1,10 @@
..@@.@@@@.
@@@.@.@.@@
@@@@@.@.@@
@.@@@@..@.
@@.@@@@.@@
.@@@@@@@.@
.@.@.@.@@@
@.@@@.@@@@
.@@@@@@@@.
@.@.@@@.@.

136
04_b/input Normal file
View File

@@ -0,0 +1,136 @@
@@@@@.@..@@.@@..@..@@@@.@@@...@@...@@.@@@@.@..@@....@.....@@..@@@@@@.@@.@@.@@.@@.@..@@@@@.@@@@@@@.@@@@@.@@@@@@@@@@@.@..@@@@..@@.@....@.@
.@@@@..@@@@@@..@.@@.@@@.@@@..@@@@@@.@...@@@@@.@@@@.@.@@.....@@@@@@.@@@@@.@@@@..@@.@.@@.@.@@.@@@@.@@.@@@@@@@.@@@..@@@@....@@@..@....@@...
.@@.@@....@@@..@.@.@@@@@@@@@.@@.@.@.@@@@..@@.@.@@@.@@@....@.@.@.@.@@.@..@@@@@@.@@@@@.@@@@.@..@.@@@@@.@@@@@@@..@@@@.@@@.@@@.@@@.@.@@@.@..
.@@@....@@@.@@.@@...@@.@@@@@@@@@@....@@.@@@@@@@@..@@.@..@@@.@.@....@...@@@.@..@@.@@@@@@..@.@@@@@@@@@@.@.@@@....@@..@@@..@@@@.@@.@@.@@@@.
@@@@@@.@@@..@@@..@@.@.@@@....@@@@..@@@.@..@.@@@@@@@@.@@@@.@.@.@@@@..@@.@..@@@@@@@...@@@.@@@@@@@.@@@@@@@..@@.@@@@@@@.@@.@@@@@@@.@...@@@@@
@@@..@.@@@@@..@@@....@.@@@@.@.@@@@.@.....@.......@..@...@@@...@@@@.@.@@.@.@@.@.@.@@@.@.......@@..@.@@..@@@@@@@@@@@@.@@.@@@...@..@@@@@.@.
@@@.@@@@.@@.@@@.@.@@.@.@..@@@@@@@@..@@@@@.@..@@@@.@@@..@@..@@.@@@@@@..@@@@@@@@.@.@@@.@...@.@.@@@@@@...@@@@.@@@@@@@..@.@@.@.@@@@@@@@@.@@.
@@...@@@@...@@@@@@@@@.@@@.@@@@..@@@@.@@@@@@.@.@.@.@@@@@.@@@@@.@@@@@@@@.@@..@.@.....@.@@@@@@.@@@.@..@@.@@@.@@@..@.@@@@...@@@@.....@@@.@@.
@.@@@.@.@.....@@.@@.@@@@...@@@@...@@@.@@@@@@@@@@@@@@.@@@@@@..@..@@.@@@@@..@@.@@@.@@@..@.@@@@@@.@@..@.@@@.@@@@@@@@@@@.@@@@@....@@@.@@@@@@
@@@@@@@@@.@@@@@@@.@...@.@..@@@..@..@@..@@.@@.@@@.@.@@@@@@@@@@@.@.@.@@@@@@.@@@.@@.@@@@.@.@@@@@@@@@..@@@@@@.@...@.@.@@.@.@@@@@@.@@@@@.@.@.
@@@...@.@@@@....@..@@.@@@@.@.@@.@@@.@.@...@@@@@@@@..@@@@.@@@@@@@......@...@..@@@@@@@@@@.@@.@@@@..@@@@...@@.@..@@@.@..@@@.@..@@@@@@@@.@@@
@@.@..@@.@@@.@@..@..@@@.@@@@@.@@@@@@@@@@@@@.@@..@@..@.@.@@@@.@.@..@@..@.@@.@@@.@@@@@@@@@@@@@@@.@@..@@@@@@@@@@@@@@@@@@.@@.@.@@@@..@@.@@@.
@@@@.@.@@.@@@@@@@@@@.@@@.......@@@@.@..@@.@.@@@.@@@.@@.@.@@.@.@@@.@@@.@.@@@.@@@@@@@@@.@..@@.@@..@@@@@@@@.@.@@..@@@.@@@.@@.@@@@.@@@@.@.@.
.@@@.@@.@..@@@@.@..@@..@@.@@.@@@..@@@@@.@.@@@.@@@@@@@@.@@@..@@@..@..@@@@@.@@@.@@.@@.@..@@@@@.@@@@@.@@.@..@@@@.@.@@..@@.@@@@.@@.@@@@@@@@@
@@.@.@@.@.@....@@@@..@.@@@@@@@...@@@@@.@@...@@@.@@@..@....@@.@@@.@.@@..@.@@@..@@@.@.@@@...@.@@@@..@@.@@@.@..@@@@@..@@.@@@@@@@@.@@@@@@@..
.@.@@.@@@@.@.@@.@..@......@.@.@.@.@@@.@@@.@@@@.@@@@@.@@@@@@@@...@.@.@.@.@.@.@@.@@@@@@@@..@@@@.@@@@@..@.@@.@@.@@.@@@@@@@@.@.@.@@.@@@@..@@
@@@.@@@@@.@@@.@.@@.@@.@@@..@.@@.@@@@..@.@..@@@@.@@@@.@@@.@@.@@@.@@@@@@@.@@@@...@@@@..@...@@.@@@@@@@@@..@@@@@@@@@@@.@@@@@.@@@@@@..@@..@@@
@.@@@@@.@@@.@@.@@@.@@..@.@@@.@@@@@@...@..@@@@@@@@@.@@@@@@@@@@@@@@@@.@@@@@.@@@@@@@@@@@@.@.@@.@@...@.@@.@.@.@@@.@@@..@@@@@.@.@@@@@..@..@..
@@....@..@.@@.@@@@@@@.@@@.@@@@@.@@.@@.@....@@..@@.@.@@.@@.@@@@.@.@@.@@@@..@@@@@@.@@..@@@@@.@@@@@.@.@@@@...@@@@.@@@@@@@.@@@@@@@@@@..@@@.@
@@@@@....@...@@@.@@@@.@@.@.@@@@@...@@@@.@.@@..@@.@@@@@.@@.......@..@@@@@@..@@...@@@.....@.@@@@.@@@@..@@@..@@.@@@..@.@.@.@@@.@...@..@@@@@
...@@@@@@..@@@..@@@@.@.@@@@@@.@.@@@...@.@@@.@@@@@@@@@.@@...@@.@@..@@@@...@@@@.@@.@@..@.@@.@@@.@@@@@@@.@..@.@...@..@.@....@@@..@@@@@@@@@@
@.@@@@@...@..@@@.@@@.@.@.@@@.@@@....@.@@@.@@..@.@@@@@@.@@..@@@@@@..@@.@@.@.@@@..@.@..@@..@@@@@@@.@.@@@.@@@.@.@@..@@@@@@@@@@@@..@@..@@.@.
@..@..@..@@@@@..@@...@@.@@@@.@@.@@.@.@@@.@@..@@..@@@..@.@@@@..@@@@.@@@@.@@.@@@.@@@@@@@...@@.@@..@.@@@@@@.@@@@@@.@.@.@.@.@@@.@..@.@@.@.@@
@@....@@@@@..@@@@@.@@@@@@...@@@@..@@@..@@@@@@@..@.@@@@@@@@.@.@@@@@@@@@@..@.@...@.@.@@..@@.@.@@.@@@@.@@.@@@.@@@..@@...@@@.@@.@@@@.@.@@@.@
.@@@.@@.@.@.@@@.@@@@@@@.@.@@@.@@@@@@@@.@...@.@..@@.@@@@@....@@@...@.@..@@@@.@.@@.@..@@@@@@@@@.@.@@@.@@..@.@@.@.@@@@@.@@@.@@@@@.@@.@@.@@@
.@@@@@.@.@@@@@@.@..@.@.@.@@@@....@@.@..@@.@@...@@.@@.@@@..@@@.....@@@.@@...@.@@.@@@@..@@@@.@@....@@..@.@.@@.@@@@@@@@.@@@.@.@.@.@@@@@@..@
...@@@.@.@@.@.@@.@@@@@@@.@@..@..@@..@@.@@@@@.@@@@..@.@.@..@@.@..@.@@@@@@@.@.@@@@@.@..@@@@.@@.@...@..@@@@@@.@@@@@@@@@@@..@@@@@@@@.@.@@.@@
@@@...@@@@@...@@..@.@.@@.@@@@..@@@.@@@@.@@@.@@@@@@@@@.@.@..@@@.@@@@@@@@.@.@@@@@@.@@@...@.@.@@@@@..@@@.@.@@.@@@.@..@@@.@@@@@.@@.@....@.@@
@@.@@@@..@.@@@@@@@.@.@@@@@@@..@@.@@...@@@..@@@@@@@@@.@...@@@@.@@...@@@@@.@.@@@@..@.@@@@...@@.@@@@...@@@.@.@@@.@@.@.@@@.@@.@@...@@..@@@@@
.@@...@@@@@@.@.@@@.@...@@@@@@..@@@@@.@@.@@@@@@@@@@@@.@@@@@.@.@@..@@@@@.@@.@..@@.@.@@@.@@@..@..@@@.@.@@@@@.@.@@.@@.@.@@.@@@..@@@@@.@@@@@@
@@..@@@@@@.@@.@@@.@@@@@@.@@@@@...@..@@@.@@@.@.@..@.@@@.@@@.@@@@@@.@@@..@@.@..@..@.@@@@@.@...@@...@@@@.@@.@.@@..@@@.@.@@.@.@@@@.@@...@.@.
@.@.@@.@@@.@.@@@.@.@@@.@.@...@@@.@@...@@.....@...@@..@.@@.@.@@@@@@@.@@.@@@@@@@.@.@@@.@..@.@.@..@@@@.@@.@.@.@.@@@@@@..@.@@.@@@.@@@..@@..@
@.@.@@@@.@@@@..@..@@.@@@@@@......@@@..@@..@.@@@@@.@@@@.@.@.@.@..@..@.@...@@@@@@.@.@@@@.@@.@@@@@.@.@@.@@@@@...@.@@@@@.@@@@@.@...@@.@@.@@@
..@@.@@.@@@@..@....@@@@..@@.@.@.@@@@.@@.@@@...@@@.@@..@....@@...@@@@.@@@@@....@@@@.@@.@@@@.@@@...@.@@@.@@@@.@@@....@.@@.@@.@...@@..@@@@@
@..@@.@@.@.@@@@@@.@@@@@@.@..@@@@.@.@@.@.@@.@@...@@@@@@.@@@@@...@@@@@@...@.@@@@@...@@@..@..@@@@.@@.@@.@@@@..@@@@@@@@@@@@@@.@@.@.@@.@.@.@@
@@@@.@.@@@.@@.@@.@@@.@..@...@@.@@@.@@@@@...@.@@@.@@@..@.@.@.@.....@@@@@@.@.@@@.@@.@@....@.@..@@@.....@@.@@@..@@@..@@.@@@.@@@.@@.@@@...@@
...@..@@.@..@@@@@@@.@@@.@@@@.@.@@@@@@@@@@@@.@@..@.@@@@@.@@@@@@@@.@@.@...@@.@@@@@@@.@@@@.@..@...@.@@@@..@@..@@.@@@.@.@...@@...@..@.@@@.@@
@@@@@@.@@.@.@.@@@.....@@@@@@@..@.@@@....@@@.@.@@@@..@@.@@@@...@@@@@@..@@@@.@..@.@.@@@.@.@@@@@.@@@@@@@@@...@@.@@@@@@@..@@...@@@@@@@.@.@.@
@@@@.@@@.@@.@.@.@@@@@@@@@.@@@@@...@.@.@@@.@@..@@@@@@@@@@@.@..@@..@@@@.@@..@@@@@@@@@@.@@..@....@@@@@@@@@.@...@@@@@.@@@.@@@@@..@@@.@@@.@@@
@.@@.@@..@@....@@.@@.@@@@@.@@@@@@@@@@@@@@..@@.@@@....@..@@@@.@..@.@@@@@@@@@.@@@...@.@@.@@...@@..@@..@.@@@@.@@@@.@.@@.@.@@.@@@@@@@@@..@.@
.@@@@@.@....@@.@.@@.@@@@@.@@.@@@@.@.@@.@.@@@.@@..@.@@@..@@.@..@@..@.@@@@@.@.@@@@..@@@@@...@@@.@.@@@@@@@@@@.@@@@.@@.@@@@..@@@.@@.@@@@@@.@
..@..@@@@@..@@@.@@@@@.@@@...@@.@@@@..@@@@@@@..@@@@.@@.@.@@.@@...@@..@@@.@@.@.@@@@...@..@@.@@@..@@..@.@@@@@@..@@@.@@@.@@.@@.@@@@...@.@@@.
@@@@@@@@@@@@.@@@.@@...@@@.@.@@.@@.@@.@.@....@@@@@.@.@@@@@@@@.@.@.@@@.@@@..@@@.@.@@...@@..@@@.@@@.@@@@@@@..@@@@@@@.@.@@@.@.@@@@@...@.@@@.
.@@@.@@.@..@@..@@.@@@.@@.@.@@@.@@@@@.@@@@@@@@.@.@.@@.@@@@@..@...@@@.@.@@@@@@@.@.@..@..@...@....@.@..@@@@@.@@@.@..@@@@.@@@.@.@@@@...@.@@@
..@@@..@@@@..@@@@.@@.@@@.@.....@@@@@@@@@.@@@@@@.@@@@@..@...@@@@@@@@@.@@.@@@@@@@..@@@@@@.@@.@@@@@.@.@@@@@@@.@@@@@@@@@..@@..@.@@@..@@@.@@@
@@@@@.@@..@..@.@..@.@@@@@@.@@@@@@@@.@@@@@@@@..@@.@..@@@@@@@@.@@@@@@...@@.....@.@@@@@@....@..@@.@..@.@@.@@.@@@.@@@@@@@.@@...@@.@@@@@@@@@@
.@.@@...@@.@.@.@@.@@@@@@@@@.@.@@@...@@..@@.@@@@.@@@@@@@@@.@@@@@@@@@...@...@@@@@.@@@@@@@@@@@@@.@@@@@@.@@@@@@@.@.@@@@.@.@.@.@.@@@@@.@@@..@
@..@@@@@.@..@@@@@@@.@@@.@@.@...@@@.@@@.@@.@.@@@.@@@@@@@.@...@@@..@@@@@@@..@.@.@..@@.@@..@@@..@@.@.@@@@@@@@.@@@@.@.@..@@.@@@@..@@@@@@@@@@
@@..@@.@@@@@@@@@@@@@.@.@.@@@.@@@@@@@.@@@@@..@.@@.@..@@@.@.@.@.@@.@...@.@@@@..@@@@.@.@.@@.@..@.@@.@@@.@@@@@.@.@@@.@.@@@@@.@.@.@@.@@@...@@
@@@.@@@.@@@@@.@...@.@@@@@.@@..@..@@@..@.@.@@@@@@......@.@@.@@@@@@..@@@@@@@@@..@..@.@.@@.@@@@.@@@@.@..@@@..@@...@@@.@@@@@@.@.@......@.@@@
@@@..@..@...@@@@@@@@@@.@@@..@.@@..@@@.@@@@.@@..@@@@@..@.@..@@@@.@.@.@..@@@.@@.@.@@.@...@.@@@@@@.@..@@@@@@@@@@@@@@@.@@@@@.@@.@@@@@.@.@@..
..@@@.@@...@@@@@..@@.@@.@@@@@@@@.@@@@@@...@@....@@...@@@@@@@@@@@.@@.@@@...@@@.@@@@.@.@@@@.@@.@@@.@@@@@@@@@@..@@.@..@@.@@.@@@@.@.@@.@...@
.@@.@@..@@@@@.@@..@@@@@@.@....@.@@@@..@.@..@.@@@...@@@.@.@@@@@@@.@.@@.@@.@@.@@.@@...@@@@@@.@@@@.@.@@@@@@@@...@@.@@@.@@.@@@@@.@...@@@@@@@
.@@@@.@@@@@.@@@.@@.@.@.@@@.@.@.@@..@@@.@@...@@.@@.@@.@@@.@@@@@@.@.@@@.@..@..@@.@..@@@@@.@@.@.@@.@@.@..@@.@..@@@@.@@..@@@.@@@@@@@@.@.@..@
@@.@....@@@.@@.@@..@.@.@.@.@.@@..@@@@@.@@@..@@....@@.@@@..@@@@@..@.@.@@@@.@@@@.@@@@...@@@..@@@@@@.@..@@@.@@@@@@@@@@@..@@..@@@@.@@.@.@..@
..@.@@.@.@@@....@@@.@.@@@@@@@@@@.@@@...@.@@.@@.@@@@@@@.@.@@@@@@@@.@...@@@.@@@@@..@.@@.@..@.@@@@@..@@@@@@@@@@..@@.@@@@.@@@@@@@@@@...@..@.
@@..@@.@@@@@@@..@@..@@@@.@.@.@@.@.@@@@.@@@.@.@@..@....@@@.@@@....@@.@@@.@@...@@@..@@.@@...@@@.@@@....@@@.@@@.@@@@..@@..@.@@.@@..@@@.@@@@
@@.@.@@@@@@@@@@@@@..@@@..@@.@@@@@@@@@@@@.@..@.@@@@@.@.@@@..@@.@@@@@...@@..@@@..@...@@.@..@.@...@@....@.@@.@..@.@@@@@@.@@@.@.@@.@.@@.@@..
@.@.@@@@@@@@@@..@..@@.@.@@@@@@@@.@@..@@@@@.@@@@@.@..@..@@@.@@@.@@@@.@.....@@@@.@@@@@@@@@@.@@@@@.@@@..@@@.@@@..@.....@@...@..@.@@@..@@@@@
....@@@@.@..@@@.@@@@...@@@@.@.@.@.@@..@....@@..@@@.@....@@@.@@@..@@@@@....@..@@.@.@.@@.@@@.@..@@@@.@....@@@@@@.@@@@..@.@@.@.@@.@.@@@.@.@
@.@...@@@@@@@@@.@@@@@@.@.@.@@@..@@.@.@.@@@@@@.@@....@.@@..@.@.@@@@.@@@@@@.@@@.@@.@..@@.@.@@@...@@@.@.@@..@.@@.@.@.@@@@@@@@.@@@@@...@@@@.
@@.@.@@@@@.@@@.@@@.@@@.@@@..@@@.@.@.@@@@.@..@@@@.@@@@@@@@@.@@...@@@.@@.@..@....@@@@@@@.@.@@@@@@.@@..@.@@@.@@@@@@...@.@.@....@.@.@@.@@@@.
@@@.....@..@@@@.@.@@@@@@@...@.@@@.@@@.@@.@@@@@@...@@.@.@@@...@@@@@@@..@@@...@.@...@@@@@.@@..@...@@@@@.@@@.@.@@@.@@..@.@@..@@@@@@@.@.@..@
@@@@@@@.@.@@..@@@@@@@@@...@.@.@@@@.@..@.@.@.@@.@@.@@..@@@.@@@@@.@@@@@.@@@@.@.@@.@@.@.@@..@@@@..@..@@@@@@.@.@@@@@...@@.@..@..@.@@.@.@@..@
@.@@@@@@@@..@@...@@@.@@@@..@.@@@@@@...@.@@.@@@@@@.@@@@.@@..@.@.@@..@@..@@.@..@.@@..@..@@@@...@@@.@@.@@.@@.@@@@@..@@@.@..@.@@.@@@@@@...@.
@@.@.@@@@@@@@@@@@..@@@..@.@@@.@.@@@.@@@@...@@@@@@.@.@@@..@@@@@@@.@.@@@@@..@@@...@@@..@@..@...@@@@@..@@..@.@@.@.@@@@@@@@@@.@..@@@.@@@@.@.
..@@...@@@@@@@.@@.@.@@@@@@@..@@.@@@@..@@@@.@@..@@@.@@.@@.@@.@@.@.@@@..@...@.@@@@@.@@@@@@@@.@.@..@@@@@.@@.....@@@@..@@.@@@.....@@@@@..@@.
.@.@@@..@@@.@@@@@@..@@@@@@..@....@@@@@.@@@@@@.@@@...@@@@...@..@@.@@@@@@@@@@.@.@@@.@.@@..@.@@@@.@@.@.@..@.@@@@@@@..@@@@@@@@@..@.@....@.@@
@@@@@@@@@..@@...@@@@.@@@@.@....@.@@@@@@.@@@@@@@.@@.@.@@.@@@..@@@@@@.@@.@@.@@@@@@...@@@@@@@@@.@@@@..@@@..@..@..@@.@.@@@.@@@...@@...@..@@@
@@@..@.@@@.@@@..@.@...@@.@@@...@.@@..@.@@@@@@.@....@@.@@.@@@@@@@@.@@@@@@..@@.@.@.@@@@@..@..@@@.@.@..@@.@@...@.@@@@@.@..@@..@...@@.@@@..@
@..@@.@@@@@@.@.@@..@.@@@@@.@@@@@@@.@.@@@.@..@@@@@.@@@@@@@..@.@@@@@...@@@.@@.@.@@.@..@.@..@@@..@@@@@@@@@@@..@@.@.@@@@@.@@@..@@@......@@.@
.@@.@.@@@.@@.@.@@@@..@@@@@@..@..@@@@....@.@..@@.@@@@..@@@@.@@@@@@@@@...@.@@.@@@@.@@@@@@@@@..@.@@@@@@@@@@@@@@.@@@..@@.@@.....@@@@@@@@@...
@...@@@@.@@@@.@@@.@...@.@.@@.@@..@@..@..@@@@..@.@@.@@@.@@@@@@@@.@@@.@...@.@....@.@@.@@.@@.@..@@.@@.@@.@@.@@@@@.@@@@.@@@@@.@@.@@@@@..@.@@
@@@@@@@@..@@...@@..@@.@@@.@.@.@@@..@.@@@.@.@.@@@.@@@.@@...@@@@.@.@@@@@@@.@.@@@.@@.@@@.@@.@@@@@@.@.@@.@.@.@@@..@@@@.@@@@@@@....@@.@@...@@
@@@.@@@@@@@@@@@.@..@.@....@@@@@.@@@@@..@@@@.@@......@@@@@@@.@.@@@.@..@@@@.@.@@@@@.@@@.@..@.@@...@.@.@.@@.@...@..@@@..@@@.@..@@@@.@..@@@@
...@@.@@@.@@.@@@@@..@@..@@.@@...@.@@.@..@.@@@@.@@@...@..@@@@@@@@@@@@@.@@@@.@.@.@@.@@@.@.@@@@.@..@@@@.@.@@.@@.@@....@@..@@@@...@@@@@.@@.@
@@@@@......@@.@@@.@@...@@@@@@@.@.@@@....@@.@..@@.@@.@@@@@@@@@@@@..@....@@.@.@@.@@@@@@@@.@.@@@.@.@.@@@@@@@@@..@@@@.@...@.@@@@@@@..@.@..@.
@@@.@@.@.@@@@.@@@.@@@.@@@@..@..@@@@.@@@.@....@@@@@.@.@@@@@@.@.@@@@@@...@@..@@@.@@..@..@..@.@..@@@@.@@@@@@@@@@@.@@@.@@@@.@.@@@.@@...@..@.
...@.@@@.@.@@.@@@@@...@@.@@@@....@@@@@@@@@@@..@@.@..@@...@..@@.@@@@.@..@.@@@....@@@@.@@.@.@@@@@@@...@.@@..@.@@@.@@@@@..@@@@@.@@@@@@@@@@@
@@.@@@@@@@....@..@@@@@...@@.@@@@@....@.@.@@.@@@.@@.@@@@@.@@@@@@@@@@@.@.@@.@@@@@..@.@@@@@@@.@..@.@.@.@@@@..@@@@@@.@..@@@..@..@@@...@@.@..
@@@..@.@@@.@...@@@..@.........@@.@.@@@@.@..@@@@@@@@.@@@@.@@@@@@@.@@..@..@@@..@.@@@...@@@..@.@.@@@@.@.@@..@@@@.@..@@.@@@@..@@@.@@.@..@@..
@.@@@@@..@@@.@@.@.@@.@@@@@@@..@.@@.@.@@@..@.@@@.@@@@@@.@@@@@..@@.@@..@@@@@...@@@@.@@@.@@@..@@.@@@@@..@@@@@.@@@@.@...@.@.@.@..@@@.@@@@@..
.@@@....@@...@.@.@@.@.@@@@@@@@@@.@.@..@@.@@.@@....@..@@.@..@@@.@@@@@@.@@@.@@@@.@@..@..@.@..@@@@.@@@.@@@@@@@.@@@@.@@@@@@@@.@@@@.@@@@.@.@@
@@@@@@@@.@@@.@.@@@@@@@.@......@@.@@@.@..@@@.@.@..@@.@@.@.@.@.@@.@@@@.@@@@@.@.@@@.@@.@.@.@@@@.@@..@@@.@@..@@@@.@@@@@..@@@.@@@@.@@.@.@@@.@
@.@@@@..@@@@@...@@@@.@..@@@@@.@.@..@@.@@@....@..@@@....@.@@@..@..@@.@@@@..@@@@@@@...@...@@.@@@@@@..@@@@@@..@@@@@@@@.@@@.@@@@.@.@@.@.@@@@
@@.@@.@@.@@@@@.@.@@@.@..@@..@@@@@..@@@@@@@@@..@..@@@..@@@@@.@@..@@@@@@...@.@@@..@@..@@@.@@.@@@.@..@..@@@.@@..@@@@.@@@@@@.@.@..@@@..@.@.@
.@@@@@.@@@@@.@@@@@@@@@@@@.@@.@@....@@.@@.@@@@@@.@.@@@.@.@.@.@@@@@.@....@.@@.@@.@@.@@@@...@@@.@..@..@.@@@@@..@.@..@@@@@@@@@@@@@@.@@@@...@
..@..@@@.@..@@..@@@..@@@.@..@.@@@.@@@@@@.@.@.@@@@@..@@@@@.@..@.@@.@@@.@@@@@..@@@...@@@@.@@@@@@.@.@@@@.@@.@@....@....@@......@@@@@@..@@..
@@@@@@@.@.@@@@.@.@@.@@@@.@.@@@@.@.@@@.@@@@@@.@@@..@@.@..@@..@..@.@.@.@@@.@..@@...@.@@.@@@@.@...@.@@@@.@@..@@@@@@@.@@@@.@@@@@..@@@.@@@...
.@@@..@@@@.@@@.@@@@@.@@@...@..@..@@@@@..@.@@@..@@@@.@.@@@@.@@@.@.@@@.@@@@@@.@@@@..@@@.@.@.@@@....@@@@@@..@@@.@@..@.@@.@@..@.@@@@@@.@@@@.
@@.@..@.@@@@@.@@@@@@@@@.@.@@@@@@.@.@.@@...@..@..@.@@@@@@@@@@.@.@@.@...@..@.@.@@..@@@.@..@@@@..@@..@.@.@@@@@@.@.@.@@@@@@@..@.@@@@.@@@@@@@
.@..@..@@.@@...@.@@@@@@@.@@@@@@.@@.@@.@...@..@@@.@..@@@@..@...@@@.@..@.@@.@@@.@@.@.@@@@..@...@.@.@@.@@..@..@@.@@@.@...@@..@@@@@@..@@....
@@@..@@@@@@@.@@.@@@@..@..@@@...@@@@@@@@@.@.@..@@@..@@@@.@.@....@..@@@@@..@@@@@@@@@.@@@.@..@@@@@@..@@@...@.@@@@@.@@.@.@.@...@@@.@.@@..@@.
@@@.@.@@@@....@.@@@.@@@@@@@@@@@@@@@.@@.@.@@@@@@@@@.@.@@.@@.@@@.@@.@@.@@@@@@@@.@@.@..@..@@.@@.@@@....@@..@@@@@@@@@@....@@@@@..@@.@@.@@@@.
@..@@@@@@@@@@..@@..@.@.@.@@@@@@@@@@@@.@.@@.@@.@@..@.@@@@@.@@@@@@@@.@@@..@.@....@@..@@.@..@..@@@.@.@..@.@..@@@@@@@@@@..@.@.@@@..@@@@@@.@.
@@@@@.@@..@@@@@@@@@@@.@@@.....@.@@....@@@.@@@@.@.@@@@.@.@@.@@....@@.@@@@.@@.@..@..@@@@@..@@@..@@..@@@@.@@@.@..@@.@..@@...@@@@...@@@@.@@@
@@.@..@@..@...@@@.@.@....@@..@@@@.@@@@..@@@.@@@.@@@..@@@@..@@@@@@@@..@@@@@@@@.@..@....@.@.@@@@@@.@@@@@....@@@@@....@@@@.@@@....@@.@@.@@@
@@.@@@@.@@..@.@.@..@@.@...@@..@@@..@@@@..@@@@.@@.@..@...@.@@@@.@@@@@@.@...@@@....@@@@.@.@@..@@.@@@@@@@..@..@@.@@@@@@@@@@.@.@.@@@...@.@@@
.@..@@@@@..@@@@.@@@.@@..@@@@..@@@.@@.@..@.@..@@...@@.@@@@@@@.@@@@@@.@@.@@.@@@@@@@@@@..@...@@.@@@@..@@@@.@@.@@.@..@...@@@@...@.@@@@@..@@@
....@@@..@.@@@@@@.@@@@.@@@..@.@.@@.@@@@..@@@.@@@@.@.@@.@@..@..@@@......@.@@@@.@@.@.@.@@..@.@....@@@.@@.@@@@....@@@@@.@.@@@..@..@@.@@@..@
@@@@@.@.@@@@@..@@.@@@.@.@@@@.@...@@@.@.@@@@@@@@@@@@@..@@@@@..@@@@@.@.@.@@.@@@..@@@@...@..@@.@.@@@.@@@@@..@.@.@@@.@.@.@.@..@@@@..@.@@@@..
.@.@.@@@.@.@@.@@@.@@@@..@.@@@@..@.@@@.@@.@.@.@.@@@@..@@@.@@@@.@@@@@@@@@.@.@@@@@.@.@.@@@@@.@.@@.@.@@@.@@.@.@..@@@.@@@@@.@@@@@@@@..@@@@@@@
@..@@..@@..@..@@@.@@.@@.@@@.@.@@.@@@@..@@.@...@@.@@...@@@@..@.@.@...@.@.@.@@@@@@@@@.@@@@@@@@.@@.@@..@.@.....@...@@.@@.@@..@@@@...@@@@@@@
@@@.@@.@@@..@@@.@@@@@@.@@@.@@@.@@.@@@.@@.@.@..@@.@@...@@.@@.....@.@@@@.@@@.@.@@@@@.@@..@.@@@@@@.@.@@@@.@@.@..@@@@..@@@@.@@@@..@@@@@..@@@
.@..@@@@@@@@.@@.@@.@.@@.........@@.@@.@@@..@@..@@.@.@.@..@@@@.@@@@@@.@@@..@@@.@@@@.@@.@@.@@..@@@@@@@@.@@@@...@@@@@@...@@@@@.@....@@@@@@@
@@.@.@@@.@.@@...@.@@.@@@.@@@@@.@..@@.@@@.@...@@@@@@@@.@@@.@@@@@@.@@@.@.@.@@@.@.@@@@..@..@@..@..@@.....@..@@....@.@@@@@@.@@@@@@.@@.@@@@@.
@..@@@@@@.@.@@@@.@.@@.@@.....@.@.@@@.@@@.@@@....@.@@@.@@@.@@.@@@@.@@.@@.@@@......@@@.@@@@@@@@...@@@.@.@@@..@....@.@.@.@@.@@.....@@....@@
@.@@@.@@@@@.@@.@.@...@@.@@@@@.@@@@.@.@@.@@...@@.@@@@@@@@@@@@@@@@.@@.@@@@@@@.@@@@@@..@@@@@@@..@.@@.@..@.@.@@@@@.@@@@@@@@.@@@@.@@@@@@@..@.
@@.@.@@@@....@.@.@@@@@@.@@..@@@@@@@.@.@.@@@.@@@@@...@.@@....@@.@@.@@@@@.@.@.@@..@.@.@@@..@@.@@@..@@@@@@.@@@@@...@.@@@@@.@@@@.@@.@.@.@@@@
@.@.@.@@@@@...@.@@.@@.@@@@@...@.@@..@@.@.@@@.@.@..@@.@@.@..@..@@@@@@@@@.@@@....@@..@.@@.@.@.@@@.@..@@@@@@@@@@.@.@@..@@.@@@@@@@@@@@@.@@.@
.@...@@@.@@.@@@.@@@@@@@.@@@@@@.@.@@.@@.@@.@@@@.@....@..@...@@.@@@@@@@.@@@@@@@@@@@@.@@@@@@...@@@@@..@@@.@.@..@@@@@.@@@...@@@@@.@@@@@@@@@@
.@@..@.@.@@.@@.@@@@@@@@.....@.@@.@..@@@.@@.@@.@@@@.....@.@@@@@.@@@..@.@@....@.@.@@..@..@.@@@..@@.@.@@.@@.@@@@.@@@@@..@@@@@@@...@@.@.@..@
.@.@@..@@@@@....@@@@@@@.@..@.@@@@@..@.@.@@@@@@@@@.@.@@...@.@@.@.@@.@@.@@@@@.@..@..@.@.@@@@@@@...@..@@@@@@@@.@@@@@.@.@.@@@@@.@.@.@.@.@@@@
@.@@@.@@@.@@@@.@@@@@@.@@.@@.@.@@..@...@@..@.@.@@..@@@.@.@@.@@@.@@@...@@@@.@..@@@.@.@@..@@@@@@...@@.@@@@@.@@.@@...@.@.@@.@..@@......@@@.@
.@@..@@@@@@@@@...@@.@@@@@@@.@@@@..@@@.@.@@..@@.@.@.@....@@@@@@@@.@@@.@.....@@@@...@@.@@.@.@@.@..@@@.@@@@@@@@@...@.@.@.@@@@.@@@.@@@.@@@.@
@@@...@..@@@@.@@.@@@@@.@@@@@..@@@@@@@@@.@@@..@@..@@@@.@@.@.@...@.@.@@@@@@@@@@..@@@@@@.@@...@@.@..@@@@@.@@@@@@@@.@@...@@.@.@@.@@@..@@.@@@
@@@.@@@@@@.@@.@.@@.@@@.@..@.@.....@@@@@.@@....@@.@..@@@@@.@@@..@@@..@@.@@@.@@@.@@.@@@@@@.@.@@@..@@@@.@@@..@@@..@@@.@@@....@.@@@.@...@.@.
@.@@.@@@@.@@@..@.@@@.@@.@@...@...@@..@@@@@@.@@.@@@@@@@..@@@@@@@@@.@.@@.@@@@@@..@@..@.@..@.@@@@..@@@@@@@@.@@@.@@@@..@.@.@@.@@.@@@@@@.@@@@
@..@@...@.@.@@@.@.@.....@..@.@@..@.@..@@@@.@@@..@@.@@@..@@.@@..@.@...@..@@.@..@@@.@@.@@@.@@@.@@.@@@@.@@@.@@@@.@...@@@@@.@@@@@..@@@@.@..@
.@.@@@.@@.@@.@@.@@@.@@@@@@@@..@@@...@.@@.@@.@@.@@@@@@@@.@.....@.@.@@@@@@@.@.@.@@@@@.@@@@@@@@@@@@@.@@.@@..@.@...@.@@@..@@@.@@.@.@@.@.@..@
@@@..@@@.@@@@@@@@@@.@..@@.@@@.@@@@@@..@@..@@@.@.@....@@@@@@.@@@@@@@@.@@...@@@..@@...@@@..@.@@..@@@@@..@@@@.@@@.@.@@@@...@..@.@.@@.@@.@..
..@@.@.@.@@..@...@..@...@@@.@@@@@@@@@..@@@@@@..@@@@.@@@@.@@@@...@@@@@@@@@@.@@@@@@@@..@.@@@@@@@@....@@@@@@@@@@....@@....@@@@..@.@@@.@.@@@
@.@.@@@@.@@.@.@.@@..@.@@@@.@@.@@@@.@@@@@.@@@.@@@@@@@@@.@@@@.@@.@.@@@@.@@@@.@@@@..@@@@.@.@@.@.@.@@@@@@@.@@.@@@@@...@@@@.@@@@@@@..@@@@.@@@
.@@.@@@@@@.@.@.@@@@@@..@..@@@@....@@..@@@.@@@@@...@@@@@.@@..@@@@..@.@.@@@@.@.@...@...@@.@..@@@...@@@..@.@@@@@...@@..@@@@.@@@@@...@@.@.@@
@@@@@....@...@@..@.@...@...@@@@@@.@.@@@@.@@@@@@@.@..@@@@@@@@..@@@@...@@.@@.@.@@.@@...@@@@.@.@@@.@@..@@@@.@@@....@...@.@.@@.@.@..@..@.@@@
..@.@@.@@@@@@@@.@@.@@.@@@...@@..@@@@@@@.@..@@..@@@.@@.@@.@...@@.@@@@@.@@@@@..@@@.@.@@.@@@@.@@@.@@@..@.@@@@@@@..@@@....@@@@....@@@..@.@@@
@@@.@@@.@@...@..@.@....@@@.@@..@@.@@@.@@.@@@.@@..@..@..@.@@@.@.@@@@@@@.@@..@@.@@@.@.@@@@@.@.@@@@@@@@..@@..@.@@.@@.@.@..@@.@..@.@@@@@@@@.
@@@@@.@@@.@..@@@.@@@@@@@@@@@.@@.@@@@@.@@@@@.@@..@@@@.@..@.@@@@@@...@@@@@@.@@..@@.@@.@@.@@..@@@@.@@.@...@@@@@@...@.@@@@@.@@@@@@@@@@@@.@.@
@.@..@..@....@@@@.@.@@@@@.@@@.@@@@@.@@@@@@@@...@@.@@@.@.@..@..@..@@@@@..@@.@@..@.@@.@@.@.@.@..@@.@@.@...@.@@@@@@.@.@..@.@@.@..@@@..@@@@@
@.@@@.@@.@@@@.@...@@@.@@@.@@@@@@@@.@@@@@@@@@@.@@@....@@@@.@@@...@@@.@.@@@@.@.@@@..@..@..@@.@@@@@@.@...@@@.@@@@.@@@@@@@@@....@@@.@@.@.@@.
@@@@..@@@@@.@@@@@@.@@@@...@..@@@.@@@@@@@.@.@@@.@.@.@@@@.@...@.@.@.@@...@@@@@@@@..@@@.@@...@@.@@@.@@@.@@@@@@@@@.@@@@.@@@..@@@@.@@@.@@@.@.
.@@@@@.@@@..@@@@@.@@@@@.@..@....@@.@@.@@@.@@@@@@@.@@@....@@@@@@@@@@@.@@..@.....@.@.@@@@@@@@..@...@@@.@@@@@@@@.@@.@@.@@@@.@@@@@.@@@..@.@.
@@..@.@.@.@@@@@.@.@@@....@.@.@.@.@@@@.@@@.@..@@@@@@..@@.@@@...@@@@@...@..@@@@.@.@@..@.@@.@@@@.@@@.@@@.@...@@@.@@@.@.@@@@.@@@@@@....@.@..
@.@.@@@@.@@@.@.@@@@..@@@@@@.@..@@@..@@.@@@@..@@@@.@.@.@.@@@.@.@.@@@@@@.@.@.@...@...@@..@@@@@.@@..@@@@@@@@@.@@@@.@@@.@.@@@@@@.@@@@@...@@.
.@.@..@@@@@@@.@@@@@@.@..@..@@@@@@@@@@@@@@@.@.@....@@@@@@@.@.@@.@@..@@@@.@.@.@.@@.@@.@@@@.@.@@@.@.@@@@@@@..@..@@@@@@@@.@@@@@@@.@.@.@.@@@@
...@@@@@@..@.@@@@@@@..@@@..@@@@@@@.@@...@..@@@.@@@@@...@.@.@.@@@@@@@@@@@..@@@@.@@@@.@...@.@@.@..@@.@@.@..@@@.@@@@@@@@.@.@.@.@@@..@@.@.@.

56
04_b/lst.c Normal file
View File

@@ -0,0 +1,56 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lst.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/15 16:17:12 by dgaillet #+# #+# */
/* Updated: 2025/12/15 16:26:55 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "aoc04_b.h"
#include <stdlib.h>
t_co *new_co(int i, int j)
{
t_co *co;
co = malloc(sizeof(t_co));
if (!co)
return (NULL);
co->i = i;
co->j = j;
co->next = NULL;
return (co);
}
void co_add_back(t_co **lst, t_co *new)
{
t_co *temp;
if (!lst)
return ;
if (!(*lst))
*lst = new;
else
{
temp = *lst;
while (temp->next)
temp = temp->next;
temp->next = new;
}
}
void clear_lst(t_co *lst)
{
t_co *temp = lst;
while (temp)
{
temp = lst->next;
free(lst);
lst = temp;
}
}

131
04_b/main.c Normal file
View File

@@ -0,0 +1,131 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 13:31:43 by dgaillet #+# #+# */
/* Updated: 2025/12/16 10:24:41 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "aoc04_b.h"
#include "get_next_char.h"
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
// 1428 ; to low
static char **parsing(void)
{
int fd = open("input", O_RDONLY);
char *temp = get_next_char(fd, '\n');
char *new;
char *str = NULL;
char **wall;
while (temp)
{
if (!str)
new = ft_strdup(temp);
else
{
new = ft_strjoin(str, temp);
free(str);
}
free(temp);
str = new;
temp = get_next_char(fd, '\n');
}
wall = ft_split(str, '\n');
return (free(str), wall);
}
static int is_roll(char **wall, int i, int j)
{
if (wall[i][j] == '@')
return (1);
return (0);
}
static int roll_arround(char **wall, int i, int j)
{
int rolls = 0;
int k = -1;
while (k <= 1)
{
if (i + k >= 0 && wall[i + k])
{
if (j > 0)
rolls += is_roll(wall, i + k, j - 1);
if (k)
rolls += is_roll(wall, i + k, j);
rolls += is_roll(wall, i + k, j + 1);
}
k++;
}
return (rolls);
}
static void delete_rolls(char **wall, t_co *lst)
{
while (lst)
{
wall[lst->i][lst->j] = '.';
lst = lst->next;
}
}
static int nb_forklift(char **wall)
{
int nb_fl = 0;
int temp;
int i = 0;
int j;
t_co *lst = NULL;
while (wall[i])
{
j = 0;
while (wall[i][j])
{
if (is_roll(wall, i, j))
{
temp = roll_arround(wall, i, j);
if (temp < 4)
{
nb_fl++;
co_add_back(&lst, new_co(i, j));
}
}
j++;
}
i++;
}
delete_rolls(wall, lst);
clear_lst(lst);
return (nb_fl);
}
int main(void)
{
char **wall = parsing();
int nb_fl = 0;
int temp = 0;
int i = 0;
temp = nb_forklift(wall);
while (temp)
{
nb_fl += temp;
temp = nb_forklift(wall);
}
while (wall[++i])
free(wall[i]);
free(wall);
printf("%d\n", nb_fl);
}