Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a56f335

Browse filesBrowse files
committed
Add solution to 2024-12-23
1 parent cb4ce21 commit a56f335
Copy full SHA for a56f335

File tree

Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed

‎2024/day23/solutions.py

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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.enumerate_all_cliques(G))
10+
11+
# Part 1
12+
print(sum(len(c) == 3 and any(x[0] == 't' for x in c) for c in cliques))
13+
14+
# Part 2
15+
print(",".join(sorted(cliques[-1])))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.