Skip to content

Commit

Permalink
feat(2023): day25
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleSmoke committed Dec 25, 2023
1 parent a793166 commit d52cfa4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
24 changes: 24 additions & 0 deletions 2023/day_25/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
import itertools
import math

import networkx as nx

input_file = "input"

input_graph = nx.from_edgelist(
itertools.chain(
*(
itertools.product([src], dsts.split())
for src, dsts in [line.strip().split(":") for line in open(input_file)]
)
)
)


def split_graph(graph):
graph.remove_edges_from(nx.minimum_edge_cut(graph))
return nx.connected_components(graph)


print(math.prod(map(len, split_graph(input_graph))))
26 changes: 21 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"
packages = [{include = "advent_of_code"}]

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.10"
numpy = "^1.23.5"
pylint = "^2.15.8"
black = "^22.10.0"
Expand All @@ -18,6 +18,7 @@ cpmpy = "^0.9.10"
parse = "^1.20.0"
sympy = "^1.12"
z3-solver = "^4.12.4.0"
networkx = "^3.2.1"

[tool.black]
line-length = 120
Expand Down

0 comments on commit d52cfa4

Please sign in to comment.