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.

2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
Not started
Part 1 completed
Both parts completed
from util.input import get_input

def _apply_look_and_say(s):
    counts = []
    digits = []

    current_digit = s[0]
    run_length = 1
    for digit in s[1:]:
        if digit == current_digit:
            run_length += 1
        else:
            counts.append(run_length)
            digits.append(current_digit)
            run_length = 1
        current_digit = digit
    
    counts.append(run_length)
    digits.append(current_digit) 

    s = ''
    for c, d in zip(counts, digits):
        s += f'{c}{d}'

    return s

def part_1():
    
    puzzle_input = get_input(2015, 10).strip()
    current_str = puzzle_input
    for _ in range(40):
        current_str = _apply_look_and_say(current_str)

    return len(current_str)

def part_2():
    
    puzzle_input = get_input(2015, 10).strip()
    current_str = puzzle_input
    for _ in range(50):
        current_str = _apply_look_and_say(current_str)

    return len(current_str)