Skip to content

Commit

Permalink
Add solution to 2024-12-18
Browse files Browse the repository at this point in the history
  • Loading branch information
fuglede committed Dec 18, 2024
1 parent 7ce5770 commit 8333942
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 2024/day18/solutions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from itertools import count
import networkx as nx

with open("input") as f:
ns = list(tuple(map(int, l.split(","))) for l in f.read().strip().split("\n"))


G = nx.grid_2d_graph(71, 71)
# Part 1
for p in ns[:1024]:
G.remove_node(p)
print(nx.shortest_path_length(G, (0, 0), (70, 70)))

# Part 2
for p in ns[1024:]:
G.remove_node(p)
if not nx.has_path(G, (0, 0), (70, 70)):
print(p)
break

0 comments on commit 8333942

Please sign in to comment.