summaryrefslogtreecommitdiffstats
path: root/day6/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'day6/__init__.py')
-rw-r--r--day6/__init__.py30
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 -*-
2from abc import ABC
3from typing import Iterator, Any
4
5from aoc import BaseAssignment
6
7
8class 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
23class AssignmentOne(Assignment):
24 example_result = 7
25 marker_length = 4
26
27
28class AssignmentTwo(Assignment):
29 example_result = 19
30 marker_length = 14