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:
|
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)
|
|
||||||
)
|
|
||||||
)
|
|
Loading…
Reference in a new issue