2024 Day 3
This commit is contained in:
14
2024/Day-03/day03-1.py
Executable file
14
2024/Day-03/day03-1.py
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import re
|
||||
from math import prod
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open('input.txt', 'r' ) as input_file:
|
||||
input = input_file.read()
|
||||
|
||||
res = 0
|
||||
for cmd in re.findall(r"mul\(\d+,\d+\)", input, flags=re.MULTILINE):
|
||||
digits = [int(y) for y in ''.join([x for x in cmd if x.isdigit() or x == ',']).split(',')]
|
||||
res += prod(digits)
|
||||
print(res)
|
Reference in New Issue
Block a user