From 3e0c92c972758b50f347124e433f3a329ede79d8 Mon Sep 17 00:00:00 2001 From: npc-strider Date: Thu, 10 Dec 2020 16:41:23 +0800 Subject: [PATCH] some more changes for day 10 --- 10/a.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/10/a.py b/10/a.py index 5023254..8ee04e5 100644 --- a/10/a.py +++ b/10/a.py @@ -12,21 +12,19 @@ def a(transformers): v_ = min(set(range(v+1,v+4)).intersection(transformers)) dv.append(v_ - v) v = v_ - # print(dv) - count = dict(Counter(dv)) return count[3]*count[1] def b(c, v, transformers): for v_ in set(range(v+1,v+4)).intersection(lines): - # print(v_) if v_ == max(transformers): c += 1 else: c = b(c, v_, transformers) return c -# print(b(0, 0, lines)) #This is a recursive solution. IT works but it'll take an eternity to go through the whole list of transformers. - #My solution: Split the set by 'gaps' (where there is only one path through to the next number), then multiply together +# print(b(0, 0, lines)) +## This is a recursive solution. IT works but it'll take an eternity to go through the whole list of transformers. +## My solution: Split the set by 'gaps' (where there is only one path through to the next number), then multiply together. defintely not the most optimal but it's logical for me and it works! :) def b_optimized(transformers): rel = { v: set(range(v+1,v+4)).intersection(transformers) for v in transformers } rel.pop(max(transformers))