I was trying to write a algorithm in javascript that returns all the possible 3 digit numbers numbers from a given array of length 6 For Example
var arr = [1, 2, 3, 4, 5, 6];
I have already got the combinations with the same sets of numbers in different positions in the 2D array. (The code which I took the help of)
If I have the same numbers in different combinations then I would like to remove them form the array. like I have [1, 2, 3]
at index i
in the array comtaining all the possible combinations then I would like to remove other combination with the same numbers like [2, 1, 3]
, [1, 3, 2]
and so on..
Note the array also contains numbers repeated like
[3, 3, 3]
,[2, 2, 2]
,[3, 2, 3]
and so on
I expect an 2d array
which has the values : [[1,2,3],[1,2,4],[1,2,5],[1,2,6],[1,3,4]]
and so on (24 possibilities)
Is there any way to do this?