Started 2017/24 part 1

This commit is contained in:
2024-11-30 20:13:48 +01:00
parent 0e83d8f589
commit fcd169e923
4 changed files with 31 additions and 2 deletions
+26 -1
View File
@@ -2,11 +2,12 @@
import sys,re
from pprint import pprint
sys.path.insert(0, '../../')
from fred import list2int
from fred import list2int, lprint,get_re
input_f = 'test'
part = 1
log = True
#########################################
# #
# Part 1 #
@@ -14,8 +15,32 @@ 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)