-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay16.py
30 lines (21 loc) · 811 Bytes
/
Day16.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Advent of Code 2022: Day 16
import re
def get_current_pressure(val_list, val_dict):
curr_pressure = 0
for val in val_list:
curr_pressure += val_dict[val]['flow_rate']
return curr_pressure
if __name__ == "__main__":
with open('data/test-16.txt') as f:
puzzle_input = f.read().splitlines()
valve_dict = {}
for line in puzzle_input:
source_valve = line.split(' ')[1]
flow_rate = int(re.findall("=(\d*)", line)[0])
tunnel_valves = line.replace(',', '').split(' ')[9:]
valve_dict[source_valve] = {'flow_rate': flow_rate, 'tunnel_valves': tunnel_valves}
pressure = 0
open_valves = []
priority = ['DD', 'BB', 'JJ', 'HH', 'EE', 'CC']
for t in range(30):
pressure += get_current_pressure(open_valves, valve_dict)