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

11 lines
333 B
Plaintext
Raw Normal View History

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)