day 3 puzzle 1

This commit is contained in:
Louis Heredero 2024-12-03 10:44:58 +01:00
parent 8b4120c53f
commit a8611658a2
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
5 changed files with 20 additions and 1 deletions

View File

@ -2,3 +2,5 @@
stars: 2 stars: 2
2: 2:
stars: 2 stars: 2
3:
stars: 1

1
res/examples/day3.txt Normal file
View File

@ -0,0 +1 @@
xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))

16
src/day3/puzzle1.typ Normal file
View File

@ -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
)

0
src/day3/puzzle2.typ Normal file
View File

Binary file not shown.