Skip to content

Commit

Permalink
Merge pull request #115 from wimglenn/2024/03
Browse files Browse the repository at this point in the history
day 03
  • Loading branch information
wimglenn authored Dec 23, 2024
2 parents f2390d9 + a231456 commit 9949649
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions aoc_wim/aoc2024/q03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
--- Day 3: Mull It Over ---
https://adventofcode.com/2024/day/3
"""
from aocd import data
import parse


pat = "mul({:d},{:d})"
a = sum(x * y for x, y in parse.findall(pat, data))
print("answer_a:", a)

while "don't()" in data:
data, tail = data.split("don't()", 1)
if "do()" in tail:
data += tail.split("do()", 1)[1]
b = sum(x * y for x, y in parse.findall(pat, data))
print("answer_b:", b)
3 changes: 3 additions & 0 deletions tests/2024/03/0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))
161
-
3 changes: 3 additions & 0 deletions tests/2024/03/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))
-
48

0 comments on commit 9949649

Please sign in to comment.