day3 part2

This commit is contained in:
Tyrel Souza 2024-12-03 21:24:00 -05:00
parent 60932a5324
commit cb9cc445c0
2 changed files with 17 additions and 2 deletions

View File

@ -7,7 +7,6 @@ def part1(rows):
total = 0
r = re.compile(r'mul\(\d+,\d+\)')
for row in rows:
print(row)
muls = r.findall(row)
for m in muls:
x, y = scanf("mul(%d,%d)", m)
@ -18,7 +17,22 @@ def part1(rows):
# @shared.profile
def part2(rows):
pass
total = 0
r = re.compile(r'(mul\(\d+,\d+\)|do\(\)|don\'t\(\))')
enabled = True
for row in rows:
muls = r.findall(row)
for m in muls:
if m == "don't()":
enabled = False
continue
if m == "do()":
enabled = True
continue
if enabled:
x, y = scanf("mul(%d,%d)", m)
total += x * y
print(total)
def main():

View File

@ -0,0 +1 @@
xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))