slightly more readable minimalist version
This commit is contained in:
parent
0402dbe9dd
commit
75e02dd3c6
|
@ -1,8 +1,5 @@
|
|||
with open("input.txt","r") as f:
|
||||
groups = f.read().split('\n\n')
|
||||
print(
|
||||
(
|
||||
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()
|
||||
sum(len(set.intersection(*map(set, group.splitlines()))) for group in groups)
|
||||
)
|
||||
)
|
||||
sets = [list(map(set, group.split('\n'))) for group in groups]
|
||||
reduce = lambda fn: sum(len(fn(*s)) for s in sets)
|
||||
print(reduce(set.union), reduce(set.intersection))
|
Loading…
Reference in a new issue