from functools import reduce
a = [{1, 2, 3, 5}, {2, 3, 4, 5}, {3, 4, 5}]
def intersect(x,y):
return x | y
res = reduce(intersect,a)
print(res)
{1, 2, 3, 4, 5}
def union(x,y):
return x & y
res = reduce(union,a)
print(res)
{3, 5}
from functools import reduce
a = [{1, 2, 3, 5}, {2, 3, 4, 5}, {3, 4, 5}]
def intersect(x,y):
return x | y
res = reduce(intersect,a)
print(res)
{1, 2, 3, 4, 5}
def union(x,y):
return x & y
res = reduce(union,a)
print(res)
{3, 5}