diff --git a/2017/24/solution.py b/2017/24/solution.py index 4b5e09c..8d1471c 100644 --- a/2017/24/solution.py +++ b/2017/24/solution.py @@ -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) + diff --git a/README.md b/README.md index d4f7f77..234f6bb 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ ## 2015 >@>o>O<<>>*>>*<*>>*>@<< 6 ** - >@<@>>o<>O@>@>>>@>>o<*<<<*<<<@<< 5 * + >@<@>>o<>O@>@>>>@>>o<*<<<*<<<@<< 5 ** >*>>O>@>>>@>>@>>>o<<<*<<<@>>@<>o>O<@>>oo<<>*<<>O<<>o<< 3 ** >>O<>>o>>@o>*<<@>>*>o<<<@