diff options
| author | 2022-12-06 08:55:58 +0100 | |
|---|---|---|
| committer | 2022-12-06 08:55:58 +0100 | |
| commit | e0355500ae852319b07f212919fe2090d7746332 (patch) | |
| tree | 2e1033f89cd376584e8ec7bf7af20db354aeebe1 /day6/__init__.py | |
| parent | 8b9919f784f93bdca7335354e7eea782b397fe0c (diff) | |
| download | 2022-e0355500ae852319b07f212919fe2090d7746332.tar.gz 2022-e0355500ae852319b07f212919fe2090d7746332.tar.bz2 2022-e0355500ae852319b07f212919fe2090d7746332.zip | |
Added day6
Diffstat (limited to 'day6/__init__.py')
| -rw-r--r-- | day6/__init__.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/day6/__init__.py b/day6/__init__.py new file mode 100644 index 0000000..364ae07 --- /dev/null +++ b/day6/__init__.py | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | # -*- coding: utf-8 -*- | ||
| 2 | from abc import ABC | ||
| 3 | from typing import Iterator, Any | ||
| 4 | |||
| 5 | from aoc import BaseAssignment | ||
| 6 | |||
| 7 | |||
| 8 | class Assignment(BaseAssignment, ABC): | ||
| 9 | @property | ||
| 10 | def marker_length(self) -> int: | ||
| 11 | raise NotImplementedError() | ||
| 12 | |||
| 13 | def run(self, input: Iterator) -> Any: | ||
| 14 | for line in input: | ||
| 15 | for index in range(len(line) - self.marker_length): | ||
| 16 | if ( | ||
| 17 | len(set(line[index : index + self.marker_length])) | ||
| 18 | == self.marker_length | ||
| 19 | ): | ||
| 20 | return index + self.marker_length | ||
| 21 | |||
| 22 | |||
| 23 | class AssignmentOne(Assignment): | ||
| 24 | example_result = 7 | ||
| 25 | marker_length = 4 | ||
| 26 | |||
| 27 | |||
| 28 | class AssignmentTwo(Assignment): | ||
| 29 | example_result = 19 | ||
| 30 | marker_length = 14 | ||
