diff --git a/progress.yaml b/progress.yaml index 79f8d02..c55a64b 100644 --- a/progress.yaml +++ b/progress.yaml @@ -1,4 +1,6 @@ 1: stars: 2 2: - stars: 2 \ No newline at end of file + stars: 2 +3: + stars: 1 \ No newline at end of file diff --git a/res/examples/day3.txt b/res/examples/day3.txt new file mode 100644 index 0000000..2e1a90a --- /dev/null +++ b/res/examples/day3.txt @@ -0,0 +1 @@ +xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) \ No newline at end of file diff --git a/src/day3/puzzle1.typ b/src/day3/puzzle1.typ new file mode 100644 index 0000000..b46419a --- /dev/null +++ b/src/day3/puzzle1.typ @@ -0,0 +1,16 @@ +#import "/src/utils.typ": * + +#let solve(input) = { + let matches = input.matches(regex("mul\((\d{1,3}),(\d{1,3})\)")) + let total = matches.map(m => { + m.captures.map(int) + .product() + }).sum() + return total +} + +#show-puzzle( + 3, 1, + solve, + example: 161 +) \ No newline at end of file diff --git a/src/day3/puzzle2.typ b/src/day3/puzzle2.typ new file mode 100644 index 0000000..e69de29 diff --git a/src/main.pdf b/src/main.pdf index 48d48dd..964c603 100644 Binary files a/src/main.pdf and b/src/main.pdf differ