fix
This commit is contained in:
parent
fda3e791f4
commit
139b6d7e12
@ -26,15 +26,10 @@ class Valve:
|
|||||||
def parse(rows):
|
def parse(rows):
|
||||||
valves = {}
|
valves = {}
|
||||||
for row in rows:
|
for row in rows:
|
||||||
try:
|
|
||||||
left,right = row.split(" valves ")
|
|
||||||
except ValueError:
|
|
||||||
left, right = row.split(" valve")
|
left, right = row.split(" valve")
|
||||||
|
right = right.replace("s ", "").lstrip()
|
||||||
valve, rate = scanf.scanf("Valve %s has flow rate=%d; %*s %*s to", left)
|
valve, rate = scanf.scanf("Valve %s has flow rate=%d; %*s %*s to", left)
|
||||||
if "," in right:
|
|
||||||
tunnels = right.split(", ")
|
tunnels = right.split(", ")
|
||||||
else:
|
|
||||||
tunnels = [right,]
|
|
||||||
valves[valve] = Valve(label=valve,rate=rate,tunnels=tunnels)
|
valves[valve] = Valve(label=valve,rate=rate,tunnels=tunnels)
|
||||||
|
|
||||||
for _,v in valves.items():
|
for _,v in valves.items():
|
||||||
@ -42,7 +37,6 @@ def parse(rows):
|
|||||||
return valves
|
return valves
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def part1(rows, sample=False):
|
def part1(rows, sample=False):
|
||||||
p1 = Part1(rows,sample, 30)
|
p1 = Part1(rows,sample, 30)
|
||||||
p1.run()
|
p1.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user