diff options
Diffstat (limited to 'day8/__init__.py')
| -rw-r--r-- | day8/__init__.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/day8/__init__.py b/day8/__init__.py new file mode 100644 index 0000000..21e18d2 --- /dev/null +++ b/day8/__init__.py | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | from abc import ABC | ||
| 3 | from typing import Iterator, Any, List | ||
| 4 | |||
| 5 | from aoc import BaseAssignment | ||
| 6 | |||
| 7 | |||
| 8 | class Assignment(BaseAssignment): | ||
| 9 | trees: List[str] | ||
| 10 | |||
| 11 | def row_at(self, y: int) -> List[int]: | ||
| 12 | return [int(i) for i in self.trees[y]] | ||
| 13 | |||
| 14 | def col_at(self, x: int): | ||
| 15 | return [int(i[x]) for i in self.trees] | ||
| 16 | |||
| 17 | def run(self, input: Iterator) -> Any: | ||
| 18 | self.trees = list(input) | ||
| 19 | |||
| 20 | width = len(self.trees[0]) | ||
| 21 | height = len(self.trees) | ||
| 22 | |||
| 23 | return ((width - 1) * 2) + ((height - 1) * 2) | ||
| 24 | |||
| 25 | |||
| 26 | class AssignmentOne(Assignment): | ||
| 27 | example_result = 21 | ||
