From 78198af80421c8a6ab12609bd58b3483a77da5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 24 Feb 2014 04:09:59 -0800 Subject: [PATCH] --- Array combinations as sets | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Array combinations as sets diff --git a/Array combinations as sets b/Array combinations as sets new file mode 100644 index 0000000..a843209 --- /dev/null +++ b/Array combinations as sets @@ -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) \ No newline at end of file