We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb4ce21 commit 46b6e75Copy full SHA for 46b6e75
2024/day23/solutions.py
@@ -0,0 +1,25 @@
1
+from itertools import combinations
2
+import networkx as nx
3
+
4
5
+with open("input") as f:
6
+ ls = f.read().strip().split("\n")
7
8
+G = nx.Graph(l.split("-") for l in ls)
9
+cliques = list(nx.find_cliques(G))
10
11
+# Part 1
12
+conn = set()
13
+for clique in cliques:
14
+ for a, b, c in list(combinations(clique, 3)):
15
+ if (
16
+ "t" in (a[0], b[0], c[0])
17
+ and (a, b) in G.edges()
18
+ and (b, c) in G.edges()
19
+ and (c, a) in G.edges()
20
+ ):
21
+ conn.add((a, b, c))
22
+print(len(conn))
23
24
+# Part 2
25
+print(",".join(sorted(max(cliques, key=len))))
0 commit comments