From 60da55c614df4eb4517bce8359655650f91dd556 Mon Sep 17 00:00:00 2001 From: alexo Date: Sun, 24 Dec 2023 15:30:55 +1100 Subject: [PATCH] day12: comments --- day12/day12.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/day12/day12.py b/day12/day12.py index cdedfb5..bcd7a2f 100644 --- a/day12/day12.py +++ b/day12/day12.py @@ -53,6 +53,13 @@ def set_and_return(self, state: State, value: int) -> int: return value def calculate_recursive(self, state: State) -> int: + """ + Recursive with memoization + 1. memoized + 2. state.empty -> return if we are valid + 3. state[0] == "." chop it and continue + 4. state[0] == "#". get next number, and "enforce" it, chopping things. If anything is wrong, fail + """ if state in self.big_cache: return self.big_cache[state] if len(state.items) == 0: