/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* part1.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/17 23:03:36 by tomoron #+# #+# */ /* Updated: 2025/12/03 16:31:41 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include #include #include #include "libft/libft.h" static long int is_rep(long int nb) { long int tmp; int len; long int div; tmp = nb; len = 1; while(tmp > 9) { tmp /= 10; len++; } div = pow(10, len / 2); if (nb / div == nb % div) return(nb); return(0); } long int resolve_part1(char *input, char **split) { (void)split; long int start; long int end; long int res; res = 0; while(*input) { start = atol(input); while(ft_isdigit(*input)) input++; input++; end = atol(input); while(ft_isdigit(*input)) input++; input++; if(start > end) { res = start; start = end; end = res; } while(start <= end) { res += is_rep(start); start++; } } return(res); }