+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
eb35f95
master
1import re 2from collections import Counter 3from functools import reduce 4from operator import or_ ,mul 5 6turn = lambda t : {color :int (num )for num ,color in re .findall (r"(\d+) (r|g|b)" ,t )} 7games = [[Counter (turn (t ))for t in l .split (";" )]for l in open ("input" )] 8min ,max = Counter ({"r" :0 ,"g" :0 ,"b" :0 }),Counter ({"r" :12 ,"g" :13 ,"b" :14 }) 9sum (i for i ,g in enumerate (games ,start = 1 )if max | reduce (or_ ,g )== max )) 10sum (reduce (mul ,reduce (or_ ,g ).values ())for g in games ))