summaryrefslogtreecommitdiffstats
path: root/day6/__init__.py
blob: 364ae07050c26eed3eb743253063e52fbcdaa720 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
from abc import ABC
from typing import Iterator, Any

from aoc import BaseAssignment


class Assignment(BaseAssignment, ABC):
    @property
    def marker_length(self) -> int:
        raise NotImplementedError()

    def run(self, input: Iterator) -> Any:
        for line in input:
            for index in range(len(line) - self.marker_length):
                if (
                    len(set(line[index : index + self.marker_length]))
                    == self.marker_length
                ):
                    return index + self.marker_length


class AssignmentOne(Assignment):
    example_result = 7
    marker_length = 4


class AssignmentTwo(Assignment):
    example_result = 19
    marker_length = 14