add: 2024/day03/part2
This commit is contained in:
parent
7accf6c2e8
commit
90feb14cd5
19
2024/day03/part2.py
Normal file
19
2024/day03/part2.py
Normal file
@ -0,0 +1,19 @@
|
||||
import re
|
||||
|
||||
text: str
|
||||
|
||||
with open("input.txt") as f:
|
||||
text = f.read()
|
||||
|
||||
total: int = 0
|
||||
|
||||
do_or_not: bool = True
|
||||
|
||||
for x, y, don_t, do in re.findall("mul\(([0-9]{0,3})\,([0-9]{0,3})\)|(don\'t)|(do)", text):
|
||||
if (do != ""):
|
||||
do_or_not = True
|
||||
elif (don_t != ""):
|
||||
do_or_not = False
|
||||
elif (do_or_not):
|
||||
total += int(x) * int(y)
|
||||
print(total)
|
Loading…
Reference in New Issue
Block a user