An efficient method to generate all possible ways to pair up items in a data set
问题 This is somewhat of a combinatorial problem; I'm trying to figure out an efficient way to pair up all items in a data set. For example, I have an array of length 6: [1,2,3,4,5,6], and I want to make all possible pairings of the contents in the array as so: [1,2],[3,4],[5,6] [1,2],[3,5],[4,6] [1,2],[3,6],[4,5] [1,3],[2,4],[5,6] [1,3],[2,5],[4,6] ... and so on. In this example, there would be 15 combinations total. In general, the number of possibilities in this solution should be (N-1)!! where