From ece64dc619bddd53f0e1cb0657d9b70cb2a1641a Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Sat, 25 May 2019 14:58:25 -0500 Subject: [PATCH] partial commit --- main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.py b/main.py index 56033bd..8ad3e22 100755 --- a/main.py +++ b/main.py @@ -70,6 +70,7 @@ class MainLoop(cmd2.Cmd): self.hidden = set() self.init_letters(input("Enter letters: ")) self._candidates = None + self._in_dictionary = None super().__init__() def init_letters(self, letters): @@ -79,6 +80,7 @@ class MainLoop(cmd2.Cmd): self.letters = [l for l in letters if l in LOWERCASE] self.prompt = MainLoop.prompt.format(", ".join(self.letters)) self._candidates = None + self._in_dictionary = None @property def candidates(self): @@ -86,6 +88,12 @@ class MainLoop(cmd2.Cmd): self._candidates = candidates(self.letters) return self._candidates + @property + def in_dictionary(self): + if self._in_dictionary is None: + self._in_dictionary = DICTS[self.dict].filter(self.candidates) + return self._in_dictionary + def filter(self, regex): matching_pattern = filter(regex.match, self.candidates) return DICTS[self.dict].filter(matching_pattern)