mirror of
https://github.com/balkian/gists.git
synced 2024-11-21 17:22:29 +00:00
This commit is contained in:
parent
0dfa2fb286
commit
78198af804
11
Array combinations as sets
Normal file
11
Array combinations as sets
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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)
|
Loading…
Reference in New Issue
Block a user