This commit is contained in:
Tyrel Souza 2022-12-16 01:19:30 -05:00
parent fda3e791f4
commit 139b6d7e12

View File

@ -26,15 +26,10 @@ class Valve:
def parse(rows):
valves = {}
for row in rows:
try:
left,right = row.split(" valves ")
except ValueError:
left, right = row.split(" valve")
right = right.replace("s ", "").lstrip()
valve, rate = scanf.scanf("Valve %s has flow rate=%d; %*s %*s to", left)
if "," in right:
tunnels = right.split(", ")
else:
tunnels = [right,]
valves[valve] = Valve(label=valve,rate=rate,tunnels=tunnels)
for _,v in valves.items():
@ -42,7 +37,6 @@ def parse(rows):
return valves
def part1(rows, sample=False):
p1 = Part1(rows,sample, 30)
p1.run()