summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--16.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/16.py b/16.py
index 24429a7..42f11d0 100644
--- a/16.py
+++ b/16.py
@@ -25,22 +25,22 @@ with open_day(16) as f:
m = regex.match(line)
assert(m)
valve, flow, neighbours = m.group(1, 2, 3)
- inp[intern(valve)] = (int(flow), [intern(n) for n in neighbours.split(', ')])
+ inp[valve] = (int(flow), neighbours.split(', '))
nodes = {}
for valve, (flow, neighbours) in inp.items():
- if valve != 0 and flow == 0: continue
+ if valve != 'AA' and flow == 0: continue
actual_neighbours = []
for n in neighbours:
prev = valve
for cost in count(1):
- if n == 0 or inp[n][0] != 0: break
+ if n == 'AA' or inp[n][0] != 0: break
l, r = inp[n][1]
nnext = r if l == prev else l
prev = n
n = nnext
- actual_neighbours.append((n, cost))
- nodes[valve] = Node(flow, actual_neighbours)
+ actual_neighbours.append((intern(n), cost))
+ nodes[intern(valve)] = Node(flow, actual_neighbours)
@cache
def sum_flow(open_valves):