Yes, weird description.
I guess this is what the author hid.
Suppose you use recursive function f(n) to generate permutations of the first n Titans. When you decide which guy to swap with the rightmost.
- n odd: Make the leftmost guy happy.
- n even: Blindly select one-by-one, left-to-right.
Thanks to Adrian and Snap. I got AC.
10395 - Titans in Danger
Moderator: Board moderators
Sorry , I don't understand what you meaninteplus wrote: Suppose you use recursive function f(n) to generate permutations of the first n Titans. When you decide which guy to swap with the rightmost.
- n odd: Make the leftmost guy happy.
- n even: Blindly select one-by-one, left-to-right.

Could you explain more clearly , or take "abcd" for example
thx in advance

See also Topic 1866.
I also tried this simple recursion:
Result: some permutations occur several times, up to 36. Thus others must be missing.
Greetings!
I also tried this simple recursion:
Code: Select all
perm(0): output current
perm(i): perm(i-1);
for j=1 to i: swap 0 and i;
perm(i-1);
Greetings!