Skip to content
Advertisement

How to print each possible permutation of several arrays of strings on Python?

Let’s say I have the following arrays of strings:

JavaScript

I want to print a list that contains all possible permutations of each element mentioned in the arrays above, following the order in which these arrays were set (i.e. it starts checking on Background, then goes to check Body, then Eyes, then Color, then Hands, and finishes on Extra).

The first permutation should be:

JavaScript

The second permutation should be:

JavaScript

And so on…

It can be assumed that the item None is the same as Empty.

How could I do that?

Advertisement

Answer

The following solution should work Assume arrays are as follows

JavaScript

If your lists are really large please don’t use the above solution because its time complexity is o(n^6).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement