I have read some number of implementations for example, What is the best way to find all combinations of items in an array?
What's nice about their implementation is many are Generic , not just array of int (or worse, array of positive int's only)
I cannot however find something that can take items which is array (Name array "S") of size m. Taking items from array "S", put them into another array "P" of size n (with n smaller than m, a common restriction I dont understand).
For example,
S = [-1, 1]
P[j] = [1,1,1,1], [1, -1, 1, 1], [1, -1, -1, 1], [1, -1, -1, -1], [-1, -1, -1, -1], ... [-1, 1, 1, -1], [1, -1, -1, 1], [-1, 1, -1, 1], [1, -1, 1, -1]
j = permutations = 0 ... pow(m,n), in this example pow(2, 4) = 16
Anything in C# or python please?
Also, time complexity...
References:
What is the best way to find all combinations of items in an array?