From 2aec84939ec44a64448ccbba9256e63a4fcd307e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Fuglede=20J=C3=B8rgensen?= Date: Mon, 23 Dec 2024 06:12:38 +0100 Subject: [PATCH] Add solution to 2024-12-23 --- 2024/day23/solutions.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 2024/day23/solutions.py diff --git a/2024/day23/solutions.py b/2024/day23/solutions.py new file mode 100644 index 0000000..6c0d2ed --- /dev/null +++ b/2024/day23/solutions.py @@ -0,0 +1,14 @@ +import networkx as nx + + +with open("input") as f: + ls = f.read().strip().split("\n") + +G = nx.Graph(l.split("-") for l in ls) +cliques = list(nx.enumerate_all_cliques(G)) + +# Part 1 +print(sum(len(c) == 3 and any(x[0] == 't' for x in c) for c in cliques)) + +# Part 2 +print(",".join(sorted(cliques[-1])))