mirror of
https://github.com/jneug/adventofcode.git
synced 2026-04-14 06:43:33 +02:00
Day 6
This commit is contained in:
20
2020/day6_2.py
Normal file
20
2020/day6_2.py
Normal 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]))
|
||||
Reference in New Issue
Block a user