diff --git a/2025/3/3_2.py b/2025/3/3_2.py new file mode 100644 index 0000000..58c1c81 --- /dev/null +++ b/2025/3/3_2.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# 2025 - Advent Of Code 3 - part 2 + +# file = 'input_example.txt' +file = 'input.txt' + +MAX_DIGIT = 12 + +joltage_sum = 0 +with open(file, encoding="utf-8") as f: + max_num = [0] * MAX_DIGIT + for line in f.readlines(): + pos_max = 0 + for digit in range(0, MAX_DIGIT): + max_num[digit] = 0 + for n in range(pos_max, len(line.strip()) - MAX_DIGIT + digit + 1): + if int(line[n]) > max_num[digit]: + max_num[digit] = int(line[n]) + pos_max = n + pos_max += 1 + + joltage = [str(x) for x in max_num] + print(''.join(joltage)) + + joltage_sum += int(''.join(joltage)) + +print(f'Total Joltage: {joltage_sum}') \ No newline at end of file