From 4dec21f362c03136e9811a4f4c162fcd8c50544e Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 2 Dec 2021 17:39:03 +0100 Subject: Added day 10 --- day6/__init__.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 day6/__init__.py (limited to 'day6/__init__.py') diff --git a/day6/__init__.py b/day6/__init__.py deleted file mode 100644 index f9d4f87..0000000 --- a/day6/__init__.py +++ /dev/null @@ -1,47 +0,0 @@ -from typing import Iterator, Any, Generator, List - -from aoc import BaseAssignment - - -class Assignment(BaseAssignment): - def read_input(self, example = False) -> Generator: - group = [] - for line in super().read_input(example): - if len(line) == 0: - yield group - group = [] - continue - - group.append(line) - - yield group - - -class AssignmentOne(Assignment): - def run(self, input: Iterator) -> Any: - return sum([ - len(set(''.join(group))) - for group in input - ]) - - -class AssignmentTwo(Assignment): - def everyone_same_answer_count(self, group: List): - answer_count = {} - for person in group: - for answer in person: - answer_count[answer] = answer_count[answer] + 1 \ - if answer in answer_count \ - else 1 - return sum([ - 1 - for value in answer_count.values() - if value == len(group) - ]) - - - def run(self, input: Iterator) -> Any: - return sum([ - self.everyone_same_answer_count(group) - for group in input - ]) -- cgit v1.2.3