clean up python set code
This commit is contained in:
parent
48e48a8429
commit
0402dbe9dd
|
@ -2,7 +2,7 @@ with open("input.txt","r") as f:
|
||||||
groups = f.read().split('\n\n')
|
groups = f.read().split('\n\n')
|
||||||
print(
|
print(
|
||||||
(
|
(
|
||||||
sum(map(len, [set(list(group.replace('\n',''))) for group in groups])),
|
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(map(len,[set.intersection(*map(set, map(list,group.split('\n')))) for group in groups]))
|
sum(len(set.intersection(*map(set, group.splitlines()))) for group in groups)
|
||||||
)
|
)
|
||||||
)
|
)
|
Loading…
Reference in a new issue