···22import fileinput
33from collections import Counter
4455+from utils import parse_line
66+5768def decrypt(c, n):
79 if c == '-':
···1416north_pole_sector_id = None
15171618for line in fileinput.input():
1717- name, sector, checksum = re.match(r'(\S+)-(\d+)\[(\w{5})\]', line).groups()
1919+ name, sector, checksum = parse_line(line, r'(\S+)-(\d+)\[(\w{5})\]')
1820 sector = int(sector)
19212022 real_name = ''.join(decrypt(c, sector) for c in name)
+5
2016/utils.py
···11+import re
12import math
23import operator
34from functools import total_ordering
···67LETTERS = [x for x in 'abcdefghijklmnopqrstuvwxyz']
78VOWELS = {'a', 'e', 'i', 'o', 'u'}
89CONSONANTS = set(x for x in LETTERS if x not in VOWELS)
1010+1111+1212+def parse_line(line, regex):
1313+ return re.match(regex, line).groups()
91410151116def mul(lst):