add day 03
This commit is contained in:
53
2025/3/part1.c
Normal file
53
2025/3/part1.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user