+ 1
JavaScript Permutations n choose k
I want to implement python like permutations in JavaScript such that if I have array [1,2,3,4] and I call permutations ([1, 2, 3, 4], 2) it should return all possible permutations of 2 elements from the passed array. I have only managed to return all length array permutations.
1 Answer
+ 6
You can copy Python's algorithm
https://docs.python.org/3/library/itertools.html#itertools.permutations