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

15 lines
319 B
Python
Raw Permalink Normal View History

2024-12-04 23:51:37 +00:00
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')