day 11 puzzle 1
This commit is contained in:
parent
8dddcd6224
commit
32fc0862a7
BIN
progress.png
BIN
progress.png
Binary file not shown.
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 121 KiB |
@ -18,3 +18,5 @@
|
||||
stars: 2
|
||||
10:
|
||||
stars: 2
|
||||
11:
|
||||
stars: 1
|
1
res/examples/day11.txt
Normal file
1
res/examples/day11.txt
Normal file
@ -0,0 +1 @@
|
||||
125 17
|
40
src/day11/puzzle1.typ
Normal file
40
src/day11/puzzle1.typ
Normal file
@ -0,0 +1,40 @@
|
||||
#import "/src/utils.typ": *
|
||||
|
||||
#let process(rock) = {
|
||||
if rock == 0 {
|
||||
return (1,)
|
||||
}
|
||||
let rock-str = str(rock)
|
||||
if calc.rem(rock-str.len(), 2) == 0 {
|
||||
let hl = calc.div-euclid(rock-str.len(), 2)
|
||||
return (
|
||||
int(rock-str.slice(0, hl)),
|
||||
int(rock-str.slice(hl))
|
||||
)
|
||||
}
|
||||
return (rock * 2024,)
|
||||
}
|
||||
|
||||
#let blink(rocks) = {
|
||||
let new-rocks = ()
|
||||
|
||||
for rock in rocks {
|
||||
new-rocks += process(rock)
|
||||
}
|
||||
|
||||
return new-rocks
|
||||
}
|
||||
|
||||
#let solve(input) = {
|
||||
let rocks = input.split(" ").map(int)
|
||||
for _ in range(25) {
|
||||
rocks = blink(rocks)
|
||||
}
|
||||
return rocks.len()
|
||||
}
|
||||
|
||||
#show-puzzle(
|
||||
11, 1,
|
||||
solve,
|
||||
example: 55312
|
||||
)
|
0
src/day11/puzzle2.typ
Normal file
0
src/day11/puzzle2.typ
Normal file
BIN
src/main.pdf
BIN
src/main.pdf
Binary file not shown.
Loading…
Reference in New Issue
Block a user