···11import re
22import fileinput
33from collections import defaultdict
44-from utils import parse_line, mul
44+from utils import parse_line
5566BOTS = defaultdict(list)
77OUTPUTS = defaultdict(list)
···1818 else:
1919 bot, low_t, low, high_t, high = parse_line(r'bot (\d+) .+ (\w+) (\d+) .+ (\w+) (\d+)', line)
20202121- if bot not in BOTS or len(BOTS[bot]) != 2:
2121+ if bot not in BOTS or len(BOTS[bot]) < 2:
2222 temp.append(line)
2323 continue
24242525 if 17 in BOTS[bot] and 61 in BOTS[bot]:
2626- print "Bot #%i compares 17 and 61." % bot
2626+ print "Bot #%i compares values 17 and 61." % bot
27272828 l, h = sorted(BOTS[bot][:2])
2929 BOTS[bot] = []
···3434 INSTRUCTIONS = temp
3535 temp = []
36363737-product = mul(OUTPUTS[i][0] for i in range(3))
3838-print "Product of values in outputs 0-2 is %i." % product
3737+a, b, c = (OUTPUTS[i][0] for i in range(3))
3838+print "Product of values in outputs 0-2 is %i." % (a * b * c)