slightly more readable minimalist version

This commit is contained in:
a 2020-12-06 16:27:34 -06:00
parent 0402dbe9dd
commit 75e02dd3c6

View file

@ -1,8 +1,5 @@
with open("input.txt","r") as f: with open("input.txt","r") as f:
groups = f.read().split('\n\n') groups = f.read().split('\n\n')
print( sets = [list(map(set, group.split('\n'))) for group in groups]
( reduce = lambda fn: sum(len(fn(*s)) for s in sets)
sum(len(set.union(*map(set, group.splitlines()))) for group in groups), # you can just call set() directly on string, no need to call list() print(reduce(set.union), reduce(set.intersection))
sum(len(set.intersection(*map(set, group.splitlines()))) for group in groups)
)
)