My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update day10.py

+6 -15
+6 -15
2016/day10.py
··· 3 3 from collections import defaultdict 4 4 from utils import parse_line, mul 5 5 6 - 7 6 BOTS = defaultdict(list) 8 7 OUTPUTS = defaultdict(list) 9 - 10 - inst = [line.strip() for line in fileinput.input()] 8 + INSTRUCTIONS = [line.strip() for line in fileinput.input()] 11 9 12 - while inst: 10 + while INSTRUCTIONS: 13 11 temp = [] 14 12 15 - for line in inst: 13 + for line in INSTRUCTIONS: 16 14 if 'value' in line: 17 15 val, bot = [int(x) for x in re.findall(r'(\d+)', line)] 18 16 BOTS[bot].append(val) ··· 30 28 l, h = sorted(BOTS[bot][:2]) 31 29 BOTS[bot] = [] 32 30 33 - if low_t == 'bot': 34 - BOTS[low].append(l) 35 - else: 36 - OUTPUTS[low].append(l) 31 + (BOTS if low_t == 'bot' else OUTPUTS)[low].append(l) 32 + (BOTS if high_t == 'bot' else OUTPUTS)[high].append(h) 37 33 38 - if high_t == 'bot': 39 - BOTS[high].append(h) 40 - else: 41 - OUTPUTS[high].append(h) 42 - 43 - inst = temp 34 + INSTRUCTIONS = temp 44 35 temp = [] 45 36 46 37 product = mul(OUTPUTS[i][0] for i in range(3))