1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-25 10:42:28 +00:00
gists/repos/9186599/Array combinations

14 lines
382 B
Plaintext
Raw Normal View History

2014-02-24 11:32:08 +00:00
a=set([1,2,3,4])
b=set([4,5,6,7])
c=set([7,8,9])
2014-02-24 11:18:39 +00:00
def array_combinations(*args):
2014-02-24 11:31:13 +00:00
combinations = [[i] for i in set(args[0])]
2014-02-24 11:18:39 +00:00
for arg in args[1:]:
tempcomb = []
2014-02-24 11:31:13 +00:00
for i in set(arg):
2014-02-24 11:18:39 +00:00
tempcomb += [c+[i] for c in combinations if i not in c ]
combinations = tempcomb
return combinations
res = array_combinations(a,b,c)
2014-02-24 11:31:13 +00:00
print res
2014-02-24 11:18:39 +00:00
print len(res)