I have an array with approximately 1000 elements what I want to do is generate arrays of size 100 from that array that contain every combination of elements. For example let’s say I have this array:
[A,B,C,D,E,F,G,H,I,J]
Splitting it into arrays with size two I want arrays that look like this:
[A,B]
[A,C]
[A,D]
[A,E]
[A,F]
[A,G]
[A,H]
[A,I]
[A,J]
[B,C]
...etc...
I am pretty confused on how to do this any advice would help,
Thanks
You can use the combinations function from the itertools module:
The first argument is the input list, the second argument is the length of the generated subsequences.