0

I have some number of arrays, each arrays has 3 elements, for example with 2 array:

a = {10, 20, 30}
b = {11, 12, 13}

I want to produce the following combination:

combination 1:
a = {10, 20, 30}
b = {11, 12, 13}

combination 2:
a = {10, 20, 30}
b = {13, 11, 12}

combination 3:
a = {10, 20, 30}
b = {12, 13, 11}

combination 4:
a = {30, 10, 20}
b = {11, 12, 13}

combination 5:
a = {30, 10, 20}
b = {13, 11, 12}

combination 6:
a = {30, 10, 20}
b = {12, 13, 11}

combination 7:
a = {20, 30, 10}
b = {11, 12, 13}

combination 8:
a = {20, 30, 10}
b = {13, 11, 12}

combination 9:
a = {20, 30, 10}
b = {12, 13, 11}

etc, which is 36 total combinations. If there are more than 2 arrays, then the combination will be more and more.

I need to get these combinations to add up each of the 1st, 2nd, and 3rd elements to get the results of each element. I have tried this solution but the result is not what i want. I have no idea how to do this.

  • What specifically does not work with the solution you tried? – maccettura Sep 22 '17 at 15:13
  • the solution i've tried is to produce combination of each element for each array. So, for the example above, the solution give me results such as {10, 11} {10, 12} {10,13} {20, 11} {20, 12} .. etc – Kukuh Heru Irawan Sep 22 '17 at 15:23
  • Have you looked at [this answer](https://stackoverflow.com/a/10630026/2457029), its _exactly_ what you need – maccettura Sep 22 '17 at 15:29
  • Yes, I've tried, the function is to generate permutation of an array. So i have to generate the permutation for each array, then pair it all? Because the result i need is all combination of all array with different order of element – Kukuh Heru Irawan Sep 22 '17 at 15:55

0 Answers0