From d5a4c8c9a06dbea8b83bd1a0bd8b786cc3d9af4e Mon Sep 17 00:00:00 2001 From: Kevin Yap Date: Wed, 7 Dec 2016 23:55:55 -0800 Subject: [PATCH] Add new_table function to utils.py --- 2016/starter.py | 3 ++- 2016/utils.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/2016/starter.py b/2016/starter.py index f91956b..2307e86 100644 --- a/2016/starter.py +++ b/2016/starter.py @@ -6,7 +6,7 @@ import fileinput from collections import Counter # NOQA from itertools import product, permutations, combinations, combinations_with_replacement # NOQA -from utils import parse_line, mul, factors, memoize, primes, Point # NOQA +from utils import parse_line, mul, factors, memoize, primes, new_table, Point # NOQA # Itertools Functions: # product('ABCD', repeat=2) AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD @@ -16,6 +16,7 @@ from utils import parse_line, mul, factors, memoize, primes, Point # NOQA total = 0 result = [] +table = new_table(None, width=2, height=4) for i, line in enumerate(fileinput.input()): line = line.strip() diff --git a/2016/utils.py b/2016/utils.py index 6629ec1..8e937b5 100644 --- a/2016/utils.py +++ b/2016/utils.py @@ -20,6 +20,10 @@ def parse_line(regex, line): return ret +def new_table(val, width, height): + return [[val for _ in range(width)] for _ in range(height)] + + def mul(lst): """Like sum(), but for multiplication.""" return reduce(operator.mul, lst, 1) # NOQA -- 2.51.2