def disjoint(sets):
 sets = list(sets)
 n = len(sets)
 disjoint_sets = ([None] * (2 ** n))
 for i in range((2 ** n)):
  key = setkey(i, n)
  included = [s for (s, inc) in zip(sets, key) if inc]
  excluded = [s for (s, inc) in zip(sets, key) if (not inc)]
  if any(included):
   s = reduce(set.intersection, included)
  else:
   s = set()
  s = reduce(set.difference, excluded, s)
  disjoint_sets[i] = s
 return disjoint_sets

def disjoint ( sets ) : sets = list ( sets ) n = len ( sets ) disjoint_sets = ( [ None ] * ( 2 ** n ) ) for i in range ( ( 2 ** n ) ) : key = setkey ( i , n ) included = [ s for ( s , inc ) in zip ( sets , key ) if inc ] excluded = [ s for ( s , inc ) in zip ( sets , key ) if ( not inc ) ] if any ( included ) : s = reduce ( set . intersection , included ) else : s = set ( ) s = reduce ( set . difference , excluded , s ) disjoint_sets [ i ] = s return disjoint_sets
return all disjoint subsets .