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.

Add new_table function to utils.py

+6 -1
+2 -1
2016/starter.py
··· 6 6 from collections import Counter # NOQA 7 7 from itertools import product, permutations, combinations, combinations_with_replacement # NOQA 8 8 9 - from utils import parse_line, mul, factors, memoize, primes, Point # NOQA 9 + from utils import parse_line, mul, factors, memoize, primes, new_table, Point # NOQA 10 10 11 11 # Itertools Functions: 12 12 # product('ABCD', repeat=2) AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD ··· 16 16 17 17 total = 0 18 18 result = [] 19 + table = new_table(None, width=2, height=4) 19 20 20 21 for i, line in enumerate(fileinput.input()): 21 22 line = line.strip()
+4
2016/utils.py
··· 20 20 return ret 21 21 22 22 23 + def new_table(val, width, height): 24 + return [[val for _ in range(width)] for _ in range(height)] 25 + 26 + 23 27 def mul(lst): 24 28 """Like sum(), but for multiplication.""" 25 29 return reduce(operator.mul, lst, 1) # NOQA