diff --git a/progress.png b/progress.png index 2fc8f03..13cef6b 100644 Binary files a/progress.png and b/progress.png differ diff --git a/progress.yaml b/progress.yaml index ce11f1e..5fb4a13 100644 --- a/progress.yaml +++ b/progress.yaml @@ -33,4 +33,6 @@ 17: stars: 1 18: - stars: 2 \ No newline at end of file + stars: 2 +19: + stars: 1 \ No newline at end of file diff --git a/res/examples/day19.txt b/res/examples/day19.txt new file mode 100644 index 0000000..ad43a74 --- /dev/null +++ b/res/examples/day19.txt @@ -0,0 +1,10 @@ +r, wr, b, g, bwu, rb, gb, br + +brwrr +bggr +gbbr +rrbgbr +ubwu +bwurrg +brgr +bbrgwb \ No newline at end of file diff --git a/src/day19/puzzle1.typ b/src/day19/puzzle1.typ new file mode 100644 index 0000000..5ff2869 --- /dev/null +++ b/src/day19/puzzle1.typ @@ -0,0 +1,41 @@ +#import "/src/utils.typ": * + +#let is-possible(target, towels: none) = { + if towels == none { + panic() + } + + for towel in towels { + if towel == target { + return true + } + if target.starts-with(towel) { + if is-possible(target.slice(towel.len()), towels: towels) { + return true + } + } + } + + return false +} + +#let solve(input) = { + let (towels, targets) = input.split("\n\n") + + towels = towels.split(", ") + let is-possible = is-possible.with(towels: towels) + + let total = 0 + for target in targets.split("\n") { + if is-possible(target) { + total += 1 + } + } + return total +} + +#show-puzzle( + 19, 1, + solve, + example: 6 +) \ No newline at end of file diff --git a/src/day19/puzzle2.typ b/src/day19/puzzle2.typ new file mode 100644 index 0000000..e69de29 diff --git a/src/main.pdf b/src/main.pdf index 2961588..1dd537f 100644 Binary files a/src/main.pdf and b/src/main.pdf differ