#!/bin/python3 import sys,re from pprint import pprint sys.path.insert(0, '../../') from fred import list2int input_f = 'test' part = 1 ######################################### # # # Part 1 # # # ######################################### def parse_input(input_str): pattern = r"^(s(\d+)|x(\d+)/(\d+)|p([a-zA-Z])/([a-zA-Z]))$" match = re.match(pattern, input_str) if match: if match.group(2): return ('s', int(match.group(2))) elif match.group(3) and match.group(4): return ('x', int(match.group(3)), int(match.group(4))) elif match.group(5) and match.group(6): return ('p', match.group(5), match.group(6)) return None if part == 1: with open(input_f) as file: for line in file: ######################################### # # # Part 2 # # # ######################################### if part == 2: exit()