1
0
mirror of https://github.com/balkian/gists.git synced 2024-12-22 14:28:12 +00:00
gists/python array and frozenset combinations/Array combinations as sets

11 lines
394 B
Plaintext
Raw Normal View History

2014-02-24 12:09:59 +00:00
def array_combinations(*args):
combinations = set([frozenset([i]) for i in set(args[0])])
for arg in args[1:]:
tempcomb = []
for i in set(arg):
tempcomb += [frozenset(list(c)+[i]) for c in combinations if i not in c ]
combinations = set(tempcomb)
return [list(comb) for comb in combinations]
res = array_combinations(a,b)
print res
print len(res)