-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday6.py
More file actions
27 lines (18 loc) · 679 Bytes
/
day6.py
File metadata and controls
27 lines (18 loc) · 679 Bytes
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
from typing import List
from pprint import pprint
def get_count_of_group(group: str) -> int:
"""ab\nac"""
group = set([x for x in group.strip() if x != '\n'])
return len(group)
def get_anyone_counts(lst_of_groups: List[str]) -> int:
return sum([get_count_of_group(x) for x in lst_of_groups])
def get_input() -> List[str]:
with open('inputs/day6.txt') as f:
data = f.read()
data = data.split('\n\n')
return data
print(get_anyone_counts(get_input()))
def part2(lst_of_str: List[str]) -> int:
a = [[set(x) for x in y.split()] for y in lst_of_str]
return sum([len(x[0].intersection(*x)) for x in a])
print(part2(get_input()))