1

I need to get all possible combinations nCr of all possible sizes of a numpy array.

[1,2,3,4,5]

should give us a set of arrays:

[1],[2],[3],[4],[5]
[1,2],[1,3],[1,4],[1,5],[2,3],[2,4],[2,5],[3,4],[3,5]
[1,2,3],[1,2,4],[1,2,5]...[3,4,5]
[1,2,3,4],[1,2,3,5],[1,2,4,5],[1,3,4,5],[2,3,4,5]
[1,2,3,4,5]

Is there a clever way to do that?

for convenience one can do all arrays of fixed length (5): [1,0,0,0,0], [2,0,0,0,0] etc

DDR
  • 459
  • 5
  • 15
  • 3
    Does this answer your question? [How to get all subsets of a set? (powerset)](https://stackoverflow.com/questions/1482308/how-to-get-all-subsets-of-a-set-powerset) – scleronomic Feb 27 '20 at 09:44

0 Answers0