Something went wrong. Try again.
My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code
advent-of-code python
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344import os # NOQAimport sys # NOQAimport re # NOQAimport math # NOQAimport copy # NOQAimport fileinputfrom string import ascii_uppercase, ascii_lowercase # NOQAfrom collections import Counter, defaultdict, deque, namedtuple # NOQAfrom itertools import count, product, permutations, combinations, combinations_with_replacement # NOQA
from utils import parse_line, parse_nums, mul, all_unique, factors, memoize, primes, resolve_mapping # NOQAfrom utils import chunks, gcd, lcm, print_grid, min_max_xy # NOQAfrom utils import new_table, transposed, rotated # NOQAfrom utils import md5, sha256, knot_hash # NOQAfrom utils import VOWELS, CONSONANTS # NOQAfrom utils import Point, DIRS, DIRS_4, DIRS_8 # NOQA # N (0, 1) -> E (1, 0) -> S (0, -1) -> W (-1, 0)
# Itertools Functions:# product('ABCD', repeat=2) AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD# permutations('ABCD', 2) AB AC AD BA BC BD CA CB CD DA DB DC# combinations('ABCD', 2) AB AC AD BC BD CD# combinations_with_replacement('ABCD', 2) AA AB AC AD BB BC BD CC CD DD
tot = 0res = []board = {}table = new_table(None, width=2, height=4)
# Uncomment for multi-group style inputs. :c# data = ''.join([line for line in fileinput.input()])# groups = [g.split('\n') for g in data.split('\n\n')]
for y, line in enumerate(fileinput.input()): line = line.strip() nums = parse_nums(line) data = parse_line(r'', line)
for x, c in enumerate(line): board[Point(x, y)] = c
if y == 0: print(data)