Reputation: 125
May be similar question is asked in the past, but i was not able to find a solution for my problem. I have an 2d array of integers like this {{1,2,3},{7,5},{4,9}}
, i want to get all the possible combinations for the array elements.
Output should be -
{{1,7,4},{1,7,9},{1,5,4},{1,5,9},{2,7,4},{2,5,9},{3,7,4},{3,5,9}}
Can anyone help me in this ?
Upvotes: 0
Views: 104
Reputation: 171114
In groovy (which I assume you want):
[[1,2,3],[7,5],[4,9]].combinations()
Upvotes: 3