python combinators list with constraints without itertools : <p>suppose I have a list with following elements [a,b,c,d,e]</p>

<p>how can I generate all possible combinations in such a way that every value can be moved to right, left or at the same position. For example with the above list all possible required combinations are </p>

<pre><code>(a, b, c, d, e)
(a, b, c, e, d)
(a, b, d, c, e)
(a, c, b, d, e)
(a, c, b, e, d)
(b, a, c, d, e)
(b, a, c, e, d)
(b, a, d, c, e)
</code></pre>

<p>One way I can think of is, find all permutations and then filter according to the conditions described above but itertools won't work when the list size is 15 for example. Any idea how can I do this for large list?</p>
