day 3 puzzle 1
This commit is contained in:
parent
8b4120c53f
commit
a8611658a2
@ -1,4 +1,6 @@
|
||||
1:
|
||||
stars: 2
|
||||
2:
|
||||
stars: 2
|
||||
stars: 2
|
||||
3:
|
||||
stars: 1
|
1
res/examples/day3.txt
Normal file
1
res/examples/day3.txt
Normal 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
16
src/day3/puzzle1.typ
Normal 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
0
src/day3/puzzle2.typ
Normal file
BIN
src/main.pdf
BIN
src/main.pdf
Binary file not shown.
Loading…
Reference in New Issue
Block a user