diff --git a/progress.png b/progress.png index 233e9c1..b605cb2 100644 Binary files a/progress.png and b/progress.png differ diff --git a/progress.yaml b/progress.yaml index 49ee180..d7d18bc 100644 --- a/progress.yaml +++ b/progress.yaml @@ -17,4 +17,6 @@ 9: stars: 2 10: - stars: 2 \ No newline at end of file + stars: 2 +11: + stars: 1 \ No newline at end of file diff --git a/res/examples/day11.txt b/res/examples/day11.txt new file mode 100644 index 0000000..528f9d5 --- /dev/null +++ b/res/examples/day11.txt @@ -0,0 +1 @@ +125 17 \ No newline at end of file diff --git a/src/day11/puzzle1.typ b/src/day11/puzzle1.typ new file mode 100644 index 0000000..24a9ba2 --- /dev/null +++ b/src/day11/puzzle1.typ @@ -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 +) \ No newline at end of file diff --git a/src/day11/puzzle2.typ b/src/day11/puzzle2.typ new file mode 100644 index 0000000..e69de29 diff --git a/src/main.pdf b/src/main.pdf index 46198a1..3a29b5b 100644 Binary files a/src/main.pdf and b/src/main.pdf differ