Skip to content

Commit

Permalink
Day 25: Snowverload
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemient committed Dec 25, 2023
1 parent e3b945e commit edbe36d
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 140 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Development occurs in language-specific directories:
|[Day22.hs](hs/src/Day22.hs)|[Day22.kt](kt/aoc2023-lib/src/commonMain/kotlin/com/github/ephemient/aoc2023/Day22.kt)|[day22.py](py/aoc2023/day22.py)|[day22.rs](rs/src/day22.rs)|
||[Day23.kt](kt/aoc2023-lib/src/commonMain/kotlin/com/github/ephemient/aoc2023/Day23.kt)||[day23.rs](rs/src/day23.rs)|
|[Day24.hs](hs/src/Day24.hs) ½|[Day24.kt](kt/aoc2023-lib/src/commonMain/kotlin/com/github/ephemient/aoc2023/Day24.kt) ½|[day24.py](py/aoc2023/day24.py) ½|[day24.rs](rs/src/day24.rs) ½|
|[Day25.hs](hs/src/Day25.hs)|||[day25.rs](rs/src/day25.rs)|
|[Day25.hs](hs/src/Day25.hs)||[day25.py](py/aoc2023/day25.py)|[day25.rs](rs/src/day25.rs)|
43 changes: 43 additions & 0 deletions py/aoc2023/day25.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Day 25: Snoverload
"""

import math

import networkx as nx

SAMPLE_INPUT = """
jqt: rhn xhk nvd
rsh: frs pzl lsr
xhk: hfx
cmg: qnr nvd lhk bvb
rhn: xhk bvb hfx
bvb: xhk hfx
pzl: lsr hfx nvd
qnr: nvd
ntq: jqt hfx bvb xhk
nvd: lhk
lsr: lhk
rzs: qnr cmg lsr rsh
frs: qnr lhk lsr
"""


def part1(data):
"""
>>> part1(SAMPLE_INPUT)
54
"""
gr = nx.Graph()
for line in data.splitlines():
if not line:
continue
src, dsts = line.split(":", maxsplit=1)
gr.add_edges_from((src, dst) for dst in dsts.split())
gr.remove_edges_from(nx.minimum_edge_cut(gr))
return math.prod(
len(component) for component in nx.components.connected_components(gr)
)


parts = (part1,)
Loading

0 comments on commit edbe36d

Please sign in to comment.