mirror of
https://github.com/balkian/gists.git
synced 2024-12-23 14:58:11 +00:00
This commit is contained in:
parent
5691cd367b
commit
9cfc2da265
13
frozen_combination.py
Normal file
13
frozen_combination.py
Normal file
@ -0,0 +1,13 @@
|
||||
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)
|
Loading…
Reference in New Issue
Block a user