summaryrefslogtreecommitdiffstats
path: root/day6/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'day6/__init__.py')
-rw-r--r--day6/__init__.py47
1 files changed, 0 insertions, 47 deletions
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 @@
1from typing import Iterator, Any, Generator, List
2
3from aoc import BaseAssignment
4
5
6class Assignment(BaseAssignment):
7 def read_input(self, example = False) -> Generator:
8 group = []
9 for line in super().read_input(example):
10 if len(line) == 0:
11 yield group
12 group = []
13 continue
14
15 group.append(line)
16
17 yield group
18
19
20class AssignmentOne(Assignment):
21 def run(self, input: Iterator) -> Any:
22 return sum([
23 len(set(''.join(group)))
24 for group in input
25 ])
26
27
28class AssignmentTwo(Assignment):
29 def everyone_same_answer_count(self, group: List):
30 answer_count = {}
31 for person in group:
32 for answer in person:
33 answer_count[answer] = answer_count[answer] + 1 \
34 if answer in answer_count \
35 else 1
36 return sum([
37 1
38 for value in answer_count.values()
39 if value == len(group)
40 ])
41
42
43 def run(self, input: Iterator) -> Any:
44 return sum([
45 self.everyone_same_answer_count(group)
46 for group in input
47 ])