1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-22 09:42:28 +00:00
gists/repos/9186870/frozen_combination.py
J. Fernando Sánchez 44c3bd604a Add 'repos/9186870/' from commit '9cfc2da26524287f6166cc20ca88ad568f762143'
git-subtree-dir: repos/9186870
git-subtree-mainline: 766153a055
git-subtree-split: 9cfc2da265
2021-10-30 15:13:59 +02:00

13 lines
476 B
Python

def frozen_combination(*args):
combinations = set([frozenset(),])
for arg in args:
tempcomb = set(frozenset(),)
for i in set(arg):
tempcomb.update(set([frozenset(list(c)+[i]) for c in combinations if i not in c]))
if len(tempcomb) > 0:
combinations = tempcomb
return combinations
# return [set(comb) for comb in combinations] # for sets instead of frozensets
res = frozen_combination(a,b)
print res
print len(res)