Skip to content

Instantly share code, notes, and snippets.

@MartGro
Created June 29, 2018 10:11
Show Gist options
  • Save MartGro/dabd063a44a9b28b97dfde6a8af02f10 to your computer and use it in GitHub Desktop.
Save MartGro/dabd063a44a9b28b97dfde6a8af02f10 to your computer and use it in GitHub Desktop.
import itertools
def listen_permutator(a,b):
comb = itertools.product(a,b)
comb = [flatten([j for j in i]) for i in comb]
#print(list(comb))
comb = set(tuple(sorted(i)) for i in comb if len(i) == len(set(i)))
return [list(i) for i in comb]
def flatten(l):
return flatten(l[0]) + (flatten(l[1:]) if len(l) > 1 else []) if type(l) is list else [l]
a = [1,2,3]
b = [1,1,6]
c = [7,8,9]
d = [10,11,12]
x = listen_permutator(a,b)
y = listen_permutator(x,c)
z = listen_permutator(y,d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment