From a given array I need a list of all the 1-element-swap list. I dont know how is this called so better if I explain it with an example.
For example. For a given array :
array = [1,2,3,4]
I need the output:
[2,1,3,4]
[3,2,1,4]
[4,2,3,1]
[1,3,2,4]
[1,4,3,2]
[1,2,4,3]
This means if K is the size of the array, I must get a (K(K-1))/2 output arrays.
In the example above, K=4 so 4(3)/2=6 output arrays.
I really dont know how to do it. I know there's the itertools function, but if I use itertools.permutations(array) I don't get my desired solution as this shows me all the permutations, and I only need a list of the "1 swap element" list.