summaryrefslogtreecommitdiffstats
path: root/day6/__init__.py
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2022-12-06 08:55:58 +0100
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2022-12-06 08:55:58 +0100
commite0355500ae852319b07f212919fe2090d7746332 (patch)
tree2e1033f89cd376584e8ec7bf7af20db354aeebe1 /day6/__init__.py
parent8b9919f784f93bdca7335354e7eea782b397fe0c (diff)
download2022-e0355500ae852319b07f212919fe2090d7746332.tar.gz
2022-e0355500ae852319b07f212919fe2090d7746332.tar.bz2
2022-e0355500ae852319b07f212919fe2090d7746332.zip
Added day6
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