52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* part1.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/07/17 23:03:36 by tomoron #+# #+# */
|
|
/* Updated: 2025/12/09 12:30:27 by tomoron ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "libft/libft.h"
|
|
|
|
long int resolve_part1(char *input, char **split)
|
|
{
|
|
(void)input;
|
|
int x = 0;
|
|
int y = 0;
|
|
long int res;
|
|
|
|
int map_height = 0;
|
|
|
|
res = 0;
|
|
while(split[map_height])
|
|
map_height++;
|
|
|
|
while(y < map_height - 1)
|
|
{
|
|
x = 0;
|
|
while(split[y][x])
|
|
{
|
|
if(split[y][x] == 'S')
|
|
{
|
|
if(split[y+1][x] == '^')
|
|
{
|
|
split[y + 1][x - 1] = 'S';
|
|
split[y + 1][x + 1] = 'S';
|
|
res++;
|
|
}
|
|
else
|
|
split[y + 1][x] = 'S';
|
|
}
|
|
x++;
|
|
}
|
|
y++;
|
|
}
|
|
return(res);
|
|
}
|