1

For a project that I'm currently working on I am dealing with a list of lists of integers, something of the form:

{[1,2];[5];[3,6,7]}

The idea here is that I'm trying to resolve an n-dimensional array into a list of the local maxima that occur in whatever particular axis I happen to be looking at. My question is this: I would like to get out a list of what would essentially be points in this n-dimensional space that contains every possible combination of entries of this list. For example, I would want the above to return:

{[1,5,3];[1,5,6];[1,5,7];[2,5,3];[2,5,6];[2,5,7]}

With the ordering not actually mattering to me. My first idea in how to approach this would be to boil this down to a tree where each path represents a possible combination and outputting every possible path, but I'm really not sure if this is the best way of going about it, and I am unfamiliar enough with Java's tree classes to be unsure if this would actually be straightforward to implement or not. Ideas?

Ah, my mistake, totally a duplicate.

Slater Victoroff
  • 21,376
  • 21
  • 85
  • 144
  • This page shows a class for doing 'array permutations' in java, near the middle of the page. Looks pretty good to me, but might need some rework to support numbers. http://stackoverflow.com/questions/2920315/permutation-of-array – Tim Jul 30 '12 at 15:39
  • 2
    Possible duplicate http://stackoverflow.com/questions/9591561/java-cartesian-product-of-a-list-of-lists – mishadoff Jul 30 '12 at 15:40

0 Answers0