Files
aoc2020/day06/module.py
2020-12-07 11:48:15 +01:00

47 lines
795 B
Python

from aoc.input import get_input
import collections
import re
from aoc.partselector import part_one, part_two
def pw(line):
return line.strip()
def p1():
inp = get_input(pw)
groups = []
group = []
for i in inp:
if i == '':
groups.append(group)
group = []
else:
group.append(i)
count = 0
for g in groups:
answers = set()
for p in g:
for x in p:
answers.add(x)
count += len(answers)
print(count)
return groups
def p2(r):
count = 0
for g in r:
s = set(g[0])
for p in g[1:]:
s = s.intersection(p)
count += len(s)
print(count)
return 0
if part_one():
result1 = p1()
if part_two():
p2(result1)