Files
aoc/2025/3/part1.c
2025-12-03 20:03:55 +01:00

54 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/03 16:40:31 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include "libft/libft.h"
static long int get_max_jolt(char *line)
{
char *first;
char *second;
long int max;
long int tmp;
first = line;
max = 0;
while(*first)
{
second = first + 1;
while(*second)
{
tmp = ((*first - '0') * 10) + (*second - '0');
if(tmp > max)
max = tmp;
second++;
}
first++;
}
return(max);
}
long int resolve_part1(char *input, char **split)
{
(void)input;
long int res;
res = 0;
while(*split)
{
res += get_max_jolt(*split);
split++;
}
return(res);
}