9
I have the two following lists:
l1 = [1, 2, ,3]
l2 = [x, y]
And would like to have all lists of 5 elements keeping the order of l1 only. Say:
[x, y, 1, 2, 3],
[x, 1, y, 2, 3],
[x, 1, 2, y, 3],
[x, 1, 2, 3, y],
[y, x, 1, 2, 3],
[y, 1, x, 2, 3],
[y, 1, 2, x, 3],
[y, 1, 2, 3, x],
[1, x, y, 2, 3],
[1, x, 2, y, 3],
[1, x, 2, 3, y],
[1, y, x, 2, 3],
[1, y, 2, x, 3],
[1, y, 2, 3, x],
...
[1, 2, 3, y, x],
...
[1, 2, 3, x, y]
Observe that the order of l1 is important and l2 is not. l2 elements run over l1+l2 positions but only the order of l1 is important.
I'm struggling with this. Any help is appreciated.