Re: "Interleave" permutation algorithm?

robertwessel2@xxxxxxxxx wrote:
) One way:
) e = 2; // Start with the first out of place element (the second)
) t = element[e];
) Loop:
) compute e2 = where element[e] *should* go
) if e == e2 then element[e2] = t, done
) swap t, element[e2]
) e = e2;
) That generalizes to general reordering if you search through the array
) looking for out of place elements, rather than just assuming it's only
) one group starting with the second element.

You'll have to generalize then, because the permutation the OP wants
is not comprised of a single group.

(In the case of 0123456789, the 3 and 6 are exchanged for example.)

SaSW, Willem
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !