Task:
Return an array with all possible pairs between the elements of an array.
Example
From a=["a", "b", "c", "d"];
return b=[["a","b"],["a","c"],["a","d"],["b","c"],["b","d"],["c","d"]]
.
Pairs can be in any order as long as all possible combinations are included and obviously ["b","d"]
is the same to ["d","b"]
.
Input
Array of unique string elements composed of chars from the class [a-z]
.
Output
2d array containing all the possible pairs of input array's elements.
Test Cases
input=["a","b","c"];
//output=[["a","b"],["a","c"],["b","c"]]
input=["a","b","c","d","e"];
//output=[["a","b"],["a","c"],["a","d"],["a","e"],["b","c"],["b","d"],["b","e"],["c","d"],["c","e"],["d","e"]]
Note: I could not find a duplicate to this challenge. If there is one, alert me with a comment to drop question.
["c","b","a"]
return? \$\endgroup\$