diff --git a/2022/python/15.png b/2022/python/15.png new file mode 100644 index 0000000..1859005 Binary files /dev/null and b/2022/python/15.png differ diff --git a/2022/python/day16.py b/2022/python/day16.py index fc60103..6fb61e4 100644 --- a/2022/python/day16.py +++ b/2022/python/day16.py @@ -43,11 +43,11 @@ def parse(rows): def part1(rows, sample=False): - p1 = Part1(rows, sample, 30) + p1 = Volcano(rows, sample, 30) p1.run() -class Part1: +class Volcano: def __init__(self, rows, sample, minutes): self.rows = rows self.sample = sample @@ -78,9 +78,7 @@ class Part1: if other == lbl: continue self.path_distances[lbl][other] = l[lbl][other] - # min( - # [len(x) for x in nx.shortest_simple_paths(self.g, lbl, other)] - # ) + self.draw() def do_tick(self, minute): pressure = 0 @@ -120,7 +118,6 @@ class Part1: pprint(_pris) return _pris - remaining = self.minutes open_order = [] while len(self.nonzero): @@ -141,15 +138,14 @@ class Part1: del self.nonzero[nxt] # keep track of which order opened open_order.append(n.label) - - print("\tMoving to", nxt) - print("\tOpening", n.label) - #distance = self.path_distances[self.cur][n.label] self.cur = n.label self.valves[self.cur].opened_at = self.minutes - (remaining - 1) + self.do_tick(self.minutes+1-remaining) + print("\tMoving to", n.label) + print("\tOpening ", n.label) + print() - # Tick tick tick remaining -= distance # Move print("\t\tMoved", distance,"distance/minutes") remaining -= 1 # open @@ -164,6 +160,9 @@ class Part1: print("total flow:", self.calculate_total_flow()) +def part2(rows, sample=False): + p2 = Volcano(rows, sample, 26) + p2.run() def main(): sample = False