Advent of Code Solutions
I have set myself a personal challenge to try and get up to date with advent of code, a set of programming challenges released each December. Each day has 2 related problems, for a total of 50 problems per year. Each button below will show my code solving that problem. Green buttons where I have solved both problems of the day, orange where I have only solved the first one and red where I haven't solved either. Not started
Part 1 completed
Both parts completed
from util.input import get_input
import re
def part_1():
puzzle_input = get_input(2024, 3)
mult_sum = 0
mul_statements = re.findall(r'mul\(\d+,\d+\)', puzzle_input)
for statement in mul_statements:
n1, n2 = map(int, statement[4:-1].split(','))
mult_sum += n1 * n2
return mult_sum
def part_2():
puzzle_input = get_input(2024, 3)
mult_sum = 0
do_blocks = puzzle_input.split('do()')
for block in do_blocks:
enabled_block = block.split("don't()")[0]
for mult in re.findall(r'mul\(\d+,\d+\)', enabled_block):
n1, n2 = map(int, mult[4:-1].split(','))
mult_sum += n1 * n2
return mult_sum