#!/bin/python3 import sys,re from pprint import pprint sys.path.insert(0, '../../') from fred import list2int, lprint,get_re input_f = 'test' part = 1 log = True ######################################### # # # Part 1 # # # ######################################### if part == 1: components = [] with open(input_f) as file: for line in file: components.append(line.rstrip()) lprint(components,log) pairs = [] for i in components: t = [] i_match = get_re(r"^(\d+)\/(\d+)$",i) if i_match.group(1) == '0': #can start pairs.append([i]) for j in (components): j_match = get_re(r"^(\d+)\/(\d+)$",j) if i_match.group(2) == j_match.group(1) or i_match.group(2) == j_match.group(2): #if i[2] == j[0] or i[2] == j[2]: t.append(j) pairs.append(t) lprint(t,log) input() lprint(pairs,log) ######################################### # # # Part 2 # # # ######################################### if part == 2: exit()