diff --git a/progress.png b/progress.png index b605cb2..19c60e9 100644 Binary files a/progress.png and b/progress.png differ diff --git a/progress.yaml b/progress.yaml index d7d18bc..5674dee 100644 --- a/progress.yaml +++ b/progress.yaml @@ -19,4 +19,4 @@ 10: stars: 2 11: - stars: 1 \ No newline at end of file + stars: 2 \ No newline at end of file diff --git a/src/day11/puzzle2.typ b/src/day11/puzzle2.typ index e69de29..6be9e06 100644 --- a/src/day11/puzzle2.typ +++ b/src/day11/puzzle2.typ @@ -0,0 +1,36 @@ +#import "/src/utils.typ": * + +#let process(rock, depth) = { + if depth == 0 { + return 1 + } + if rock == 0 { + return process(1, depth - 1) + } + let rock-str = str(rock) + if calc.rem(rock-str.len(), 2) == 0 { + let hl = calc.div-euclid(rock-str.len(), 2) + let a = int(rock-str.slice(0, hl)) + let b = int(rock-str.slice(hl)) + return process(a, depth - 1) + process(b, depth - 1) + } + return process(rock * 2024, depth - 1) +} + +#let solve(input) = { + let rocks = input.split(" ").map(int) + let total = 0 + for rock in rocks { + total += process(rock, 75) + } + return total +} + +#show-puzzle( + 11, 2, + solve, + only-example: true +) + +// Too long to recompile everytime +#show-result(228651922369703) \ No newline at end of file diff --git a/src/main.pdf b/src/main.pdf index 3a29b5b..4430ffd 100644 Binary files a/src/main.pdf and b/src/main.pdf differ