I've been trying to do something but can't wrap my head around :
I want to generate all possible permutations of n
elements in m
slots.
To be more precise, I have a 8x8 two-dimensional array, but to make it more simple, let's say it's a 64 slot list (I will transform it back to a two-dimension array later), all filled with 0
. I want to place 4 1
in this list, and generate all possible permutations, with no duplicates.
For example, if I wanted to place 2 elements in a list of 4 slots, if would give those 6 lists:
0 0 1 1
0 1 0 1
1 0 0 1
0 1 1 0
1 0 1 0
1 1 0 0
I've tried using itertools, but neither of the functions there seem to do the job, or I don't really understand them enough to find the right way to use them this way.