diff --git a/2022/python/day16.py b/2022/python/day16.py index 200b499..41db737 100644 --- a/2022/python/day16.py +++ b/2022/python/day16.py @@ -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 ") + 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,] + tunnels = right.split(", ") 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() @@ -82,7 +76,7 @@ class Part1: def move(self, where): self.tick += 1 - self.cur = self.valves[where] + self.cur = self.valves[where] print("\tMove to valve", where) def open(self):