I'm trying to create a subset of all the possible number combinations of a list of numbers. Here is an example:
List of numbers : 1,2,3,4,5,6
Subsets (3 numbers in a group) :
1,2,3
1,2,4
1,2,5
1,2,6
1,3,4
1,3,5
1,3,6
1,4,5
1,4,6
1,5,6
2,3,4
2,3,5
2,3,6
2,4,5
2,4,6
2,5,6
3,4,5
3,4,6
3,5,6
4,5,6
I'm stumped at trying to determine the looping algorithm to achieve this list. I can see that I will need a nested loop but the logic escapes me. This example contains all the possible 3 number groups but is only an example. I need to be able to scale to larger lists and more groups. Please help!
I'm a Java junkie so I'd appreciate a Java solution but would be happy with an explanation in any language and even pseudo code.
2,3,5the same as5,2,3?