Skip to content
Advertisement

Separate combination of two separate lists keeping the correspondence/dependence on each other

I have two lists of same length which have one to one correspondence:

JavaScript

I want to find combinations of these two lists separately. But the indices of combined elements must be the same for both lists.

For example, if I do:

JavaScript

I may get

JavaScript

I could’ve got

JavaScript

too because both are the same.

So whatever the combination I get I want the same indices combined for the second list too.

So if

JavaScript

gives me

JavaScript

then

JavaScript

should give me

JavaScript

or if

JavaScript

gives me

JavaScript

then

JavaScript

should give me

JavaScript

Advertisement

Answer

You could generate combinations on the indices and then index a and b. For instance:

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