Rename 2024 scripts for nicer ordering
This commit is contained in:
24
2024/d03.py
Normal file
24
2024/d03.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import re
|
||||
from lib import get_data
|
||||
from lib import ints
|
||||
|
||||
|
||||
data = get_data(__file__)
|
||||
|
||||
t1 = 0
|
||||
t2 = 0
|
||||
enabled = True
|
||||
r = re.compile(r"mul\(\d+,\d+\)|do\(\)|don't\(\)")
|
||||
for m in r.findall(data):
|
||||
if m == "do()":
|
||||
enabled = True
|
||||
elif m == "don't()":
|
||||
enabled = False
|
||||
else:
|
||||
a, b = ints(m)
|
||||
t1 += a * b
|
||||
if enabled:
|
||||
t2 += a * b
|
||||
|
||||
print(t1)
|
||||
print(t2)
|
||||
Reference in New Issue
Block a user