···66from collections import Counter, defaultdict, deque, namedtuple # NOQA
77from itertools import count, product, permutations, combinations, combinations_with_replacement # NOQA
8899-from utils import (parse_line, mul, all_unique, factors, memoize, primes, new_table, md5, sha256, knot_hash, # NOQA
1010- Point, DIRS, DIRS_4, DIRS_8) # NOQA
99+from utils import parse_line, mul, all_unique, factors, memoize, primes # NOQA
1010+from utils import new_table, transposed, rotated # NOQA
1111+from utils import md5, sha256, knot_hash # NOQA
1212+from utils import Point, DIRS, DIRS_4, DIRS_8 # NOQA
11131214# Itertools Functions:
1315# product('ABCD', repeat=2) AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD
+10
2017/utils.py
···2525 return [[val for _ in range(width)] for _ in range(height)]
262627272828+def transposed(matrix):
2929+ """Returns the transpose of the given matrix."""
3030+ return [list(r) for r in zip(*matrix)]
3131+3232+3333+def rotated(matrix):
3434+ """Returns the given matrix rotated 90 degrees clockwise."""
3535+ return [list(r) for r in zip(*matrix[::-1])]
3636+3737+2838def mul(lst):
2939 """Like sum(), but for multiplication."""
3040 return reduce(operator.mul, lst, 1) # NOQA