diff --git a/progress.png b/progress.png index a03f169..905a526 100644 Binary files a/progress.png and b/progress.png differ diff --git a/progress.yaml b/progress.yaml index 0ef3bad..b0e2791 100644 --- a/progress.yaml +++ b/progress.yaml @@ -41,4 +41,6 @@ 21: stars: 0 22: + stars: 1 +23: stars: 1 \ No newline at end of file diff --git a/res/examples/day23.txt b/res/examples/day23.txt new file mode 100644 index 0000000..d8576a8 --- /dev/null +++ b/res/examples/day23.txt @@ -0,0 +1,32 @@ +kh-tc +qp-kh +de-cg +ka-co +yn-aq +qp-ub +cg-tb +vc-aq +tb-ka +wh-tc +yn-cg +kh-ub +ta-co +de-co +tc-td +tb-wq +wh-td +ta-ka +td-qp +aq-cg +wq-ub +ub-vc +de-ta +wq-aq +wq-vc +wh-yn +ka-de +kh-ta +co-tc +wh-qp +tb-vc +td-yn \ No newline at end of file diff --git a/src/day23/puzzle1.typ b/src/day23/puzzle1.typ new file mode 100644 index 0000000..ac48d21 --- /dev/null +++ b/src/day23/puzzle1.typ @@ -0,0 +1,50 @@ +#import "/src/utils.typ": * + +#let solve(input) = { + let links = input.split("\n") + + let links-dict = (:) + + let to-test = () + for link in links { + let (a, b) = link.split("-") + if a not in links-dict { + links-dict.insert(a, ()) + } + if b not in links-dict { + links-dict.insert(b, ()) + } + links-dict.at(a).push(b) + links-dict.at(b).push(a) + if a.starts-with("t") { + to-test.push(a) + } + if b.starts-with("t") { + to-test.push(b) + } + } + + let total = 0 + let groups = () + for comp1 in to-test.dedup() { + for comp2 in links-dict.at(comp1) { + for comp3 in links-dict.at(comp2) { + if comp1 in links-dict.at(comp3) { + let group = (comp1, comp2, comp3).sorted() + if group not in groups { + total += 1 + groups.push(group) + } + } + } + } + } + + return total +} + +#show-puzzle( + 23, 1, + solve, + example: 7 +) \ No newline at end of file diff --git a/src/day23/puzzle2.typ b/src/day23/puzzle2.typ new file mode 100644 index 0000000..e69de29 diff --git a/src/main.pdf b/src/main.pdf index b943987..67cb60b 100644 Binary files a/src/main.pdf and b/src/main.pdf differ