I have to create a multiple dimensional list that looks like this :
[[[1,R],[1,R]],[[1,B],[1,B]],[[2,R],[1,B]],[[2,R],[2,B]]]...
From two lists :
[1,2] and [R,B]
My objective is to create all the possible combinations.
I've done something that is working. with a while, but when the number of combinations is huge it takes so much time. For exemple when i have n(it is the number of color) = 5 And N = 6 --> RandomedColor= [Red,white,black,green,Yellow] and liste2 = [1,2,3,4,5,6] it will take at least 5 mins to be done.
def Create_All_list_from_n(N): #Create all possible combinations of numbers with colors. if n = 2, and N = 5 then, there will be 2**5 combinations.
all_list_of_N = []
while(len(all_list_of_N) != n**N):
current_list = []
for i in range(1,N+1):
current_list.append([random.choice(RandomedColors),i])
if current_list not in all_list_of_N:
all_list_of_N.append(current_list)
print(all_list_of_N)
print(len(all_list_of_N))
return all_list_of_N
Thanks for helping !