advent-of-code-2024/day_03/part_a.py

15 lines
319 B
Python

import aocd
import re
def mul(a, b):
return int(a)*int(b)
def solve(data):
return sum(mul(*match) for match in re.findall(r'mul\((\d+),(\d+)\)', data))
if __name__ == '__main__':
solution = solve(aocd.get_data(year=2024, day=3))
print(solution)
aocd.submit(solution, year=2024, day=3, part='a')