From 074ddf258328651c70fa649d9470cd620e864890 Mon Sep 17 00:00:00 2001 From: Nathan van Ofwegen Date: Fri, 11 Dec 2020 21:38:34 +0100 Subject: [PATCH] cache monie --- day10/day10.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/day10/day10.py b/day10/day10.py index fcf67c1..048d63f 100644 --- a/day10/day10.py +++ b/day10/day10.py @@ -16,7 +16,15 @@ def part1(): print("Part 1 %d " % (diffs[1] * diffs[3])) +cache = { + +} + + def count_options(og, adapters): + if og in cache: + return cache[og] + amount = 0 adap = list.copy(adapters) @@ -29,6 +37,7 @@ def count_options(og, adapters): break amount += count_options(num, adap) + cache[og] = amount return amount