From 42876de1597c5f0f9215913884234e1325dd06ce Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Mon, 7 Dec 2020 18:29:00 +0100 Subject: [PATCH] updated --- day07/module.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/day07/module.py b/day07/module.py index 242b370..94cc962 100644 --- a/day07/module.py +++ b/day07/module.py @@ -17,14 +17,14 @@ def p1(): for element in sample[1:]: if 'no' in element: continue - data.append(element.split(' ', 1)) + data.append(tuple(element.split(' ', 1))) pwd[sample[0]] = data @functools.lru_cache(maxsize=256) def contains_gold(y): return 'shiny gold' == y or any(map(lambda x: contains_gold(x[1]), pwd[y])) - s = sum(map(lambda x: any(map(lambda x: contains_gold(x[1]), pwd[x])), pwd)) + s = sum(map(lambda x: any(map(lambda y: contains_gold(y[1]), pwd[x])), pwd)) print(s) @@ -53,12 +53,12 @@ def p2(r): if part_one(): start = time.time() result1 = p1() - print(round(time.time() - start, 6), 's') + print(round(1000*(time.time() - start), 2), 'ms') if part_two(): start = time.time() p2(result1) - print(round(time.time() - start, 6), 's') + print(round(1000*(time.time() - start), 2), 'ms')