Given an array and a length, I want to derive every possible combination of elements (non-repeating) at the specific length.
So given an array of:
arr = ['a','b','c','d']
and a length of 3, I'm after a function that outputs a 2-dimensional array as follows:
result = [
['a','b','c'],
['b','c','a'],
['c','a','b'],
. . . etc.
]
I've tried tackling this and have had a deal of difficulty.