day 1 done
This commit is contained in:
37
2025/1/part1.c
Normal file
37
2025/1/part1.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* part1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/17 23:03:36 by tomoron #+# #+# */
|
||||
/* Updated: 2025/12/01 10:45:18 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "libft/libft.h"
|
||||
|
||||
long int resolve_part1(char *input, char **split)
|
||||
{
|
||||
(void)input;
|
||||
int move_val;
|
||||
long int cur_val;
|
||||
long int res;
|
||||
|
||||
cur_val = 50;
|
||||
res = 0;
|
||||
while(*split)
|
||||
{
|
||||
move_val = ft_atoi((*split) + 1);
|
||||
if(**split == 'L')
|
||||
move_val *= -1;
|
||||
cur_val += move_val;
|
||||
if(cur_val % 100 == 0)
|
||||
res++;
|
||||
split++;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
Reference in New Issue
Block a user