This commit is contained in:
Jonas Neugebauer 2020-12-12 10:34:41 +01:00
parent bc5112c849
commit ea798b7313
2 changed files with 34 additions and 1 deletions

View File

@ -1,4 +1,17 @@
input = []
with open('day6_input.txt', 'r') as f:
group = ''
for line in f.readlines():
input.append(line.strip())
if len(line.strip()) == 0:
input.append(group)
group = ''
else:
group += line.strip()
input.append(group)
def counter(group):
return len(set(group))
print(sum(map(counter, input)))
print(input[0])
print(set(input[0]))

20
2020/day6_2.py Normal file
View File

@ -0,0 +1,20 @@
from functools import reduce
input = []
with open('day6_input.txt', 'r') as f:
group = []
for line in f.readlines():
if len(line.strip()) == 0:
input.append(group)
group = []
else:
group.append(line.strip())
input.append(group)
def intersec(s, g):
return s.intersection(set(g))
def counter(group):
return len(reduce(intersec, group, set(group[0])))
print(sum([counter(g) for g in input]))