diff --git a/2021/10/README.md b/2021/10/README.md index 9f2d059..257a216 100644 --- a/2021/10/README.md +++ b/2021/10/README.md @@ -8,7 +8,7 @@ A neat trick for part 2 is to simply reverse the order of the stack and count th
Solutions
    -
  1. 392097
  2. +
  3. 288957
  4. 4263222782
diff --git a/2021/10/python/main.py b/2021/10/python/main.py index 5846f7b..10df24c 100644 --- a/2021/10/python/main.py +++ b/2021/10/python/main.py @@ -9,11 +9,6 @@ from os.path import dirname, join # Common -def log(str): - if False: - print(str) - - def read_input(filename): data = join(dirname(__file__), '..', filename) with open(data) as f: @@ -70,7 +65,6 @@ class NavigationSubsystemLineParser(): """ Returns -1 for incomplete, 0 for valid, or the position of the first invalid character """ - log(f'Validating {self.line}') while self.position < len(self.line): expected = self._allowed_chars() char = self.line[self.position] @@ -80,7 +74,6 @@ class NavigationSubsystemLineParser(): else: expected = self.pairs[self.stack[-1]] if char != expected: - log(f'Invalid char {char} at position {self.position}. Expected {expected}') return ParseResult(ResultType.Corrupted, expected=expected, found=char) else: self.stack.pop() @@ -100,8 +93,6 @@ class NavigationSubsystem(): def count_corrupted(self) -> int: results = self.validate() - for result in results: - log(result) points_map = { ')': 3, ']': 57, @@ -134,7 +125,6 @@ class NavigationSubsystem(): if result.type == ResultType.Incomplete ] points.sort() - log(points) return points[len(points)//2] @staticmethod