From 62ba17027b3d6268982326dac9c626b851e1b079 Mon Sep 17 00:00:00 2001 From: HJ Date: Mon, 25 Dec 2023 01:06:45 -0500 Subject: day 25 complete -- 2023 complete --- aoc2023-other/day-25/day-25.rkt | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 aoc2023-other/day-25/day-25.rkt (limited to 'aoc2023-other') diff --git a/aoc2023-other/day-25/day-25.rkt b/aoc2023-other/day-25/day-25.rkt new file mode 100644 index 0000000..aa32e43 --- /dev/null +++ b/aoc2023-other/day-25/day-25.rkt @@ -0,0 +1,43 @@ +#lang racket + +(require advent-of-code + threading + graph) + +(define input + (~> (fetch-aoc-input (find-session) 2023 25 #:cache #true) + (string-split "\n") + (map (curryr string-split ": ") _))) + +(define all-wires + (for*/list ([wire-diagram (in-list input)] [devices (in-list (string-split (second wire-diagram)))]) + (list (car wire-diagram) devices))) + +;; instead of trying to solve the minimum cut problem, I generated the graph and +;; rendered it in graphviz: + +; (define out (open-output-file "graphviz")) +; (~> all-wires +; unweighted-graph/undirected +; graphviz +; (display out)) +; (close-output-port out) + +;; the bottleneck is very obvious on the graph -- +;; there's two large clusters of nodes, connected by just three edges +;; +;; from the graphviz output, the three critical wires are +;; cpq-hlx +;; hqp-spk +;; chr-zlx + +(define remove-these-three '(("cpq" "hlx") ("hqp" "spk") ("chr" "zlx"))) +(define cut-wires + (for/list ([wire (in-list all-wires)] #:unless (member (sort wire string cut-wires + unweighted-graph/undirected + scc + (map length _) + (apply * _)) \ No newline at end of file -- cgit v1.2.3