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

+5 -5
+5 -5
2016/day10.py
··· 1 1 import re 2 2 import fileinput 3 3 from collections import defaultdict 4 - from utils import parse_line, mul 4 + from utils import parse_line 5 5 6 6 BOTS = defaultdict(list) 7 7 OUTPUTS = defaultdict(list) ··· 18 18 else: 19 19 bot, low_t, low, high_t, high = parse_line(r'bot (\d+) .+ (\w+) (\d+) .+ (\w+) (\d+)', line) 20 20 21 - if bot not in BOTS or len(BOTS[bot]) != 2: 21 + if bot not in BOTS or len(BOTS[bot]) < 2: 22 22 temp.append(line) 23 23 continue 24 24 25 25 if 17 in BOTS[bot] and 61 in BOTS[bot]: 26 - print "Bot #%i compares 17 and 61." % bot 26 + print "Bot #%i compares values 17 and 61." % bot 27 27 28 28 l, h = sorted(BOTS[bot][:2]) 29 29 BOTS[bot] = [] ··· 34 34 INSTRUCTIONS = temp 35 35 temp = [] 36 36 37 - product = mul(OUTPUTS[i][0] for i in range(3)) 38 - print "Product of values in outputs 0-2 is %i." % product 37 + a, b, c = (OUTPUTS[i][0] for i in range(3)) 38 + print "Product of values in outputs 0-2 is %i." % (a * b * c)