I have an Array of PlayerIDs
Players = [ 1, 2, 4, 12, 14, 16 ]
I now need an algorithm that returns all possible combinations, like
[1,2], [4,12], [14,16]
[1,4], [2,12], [14,16]
[1,12], [2,4], [14,16]
[1,14], [2,4], [12,16]
...and so on, till all combinations have been listed
There is no difference between [1,2] or [2,1]. I would stay that X<Y at [X,Y]
I found the following approach [https://stackoverflow.com/a/16256122][1] which is really near to what I look for, but this algorithm doesn't group the pairings (Array of 6 Players = Group of 3 possible pairings).
Can somebody refine this algorithm that fits my needs?
Examples in Java, C++, C# or PHP are fine.
Thank you in advance!