Talk:Permutations by swapping

From Rosetta Code

Does "Python: recursive" fit this task?

The "Python: recursive" solution doesn't seem to use swaps, which I thought was the whole point of this task. We already have a Permutations task for generating permutations in general. --Spoon! 17:58, 26 July 2012 (UTC)

It also doesn't generate the output requested (it's missing the signs). Not that I think it should, though; right now, too much of this task smells of “let's write the task to force my code to be a solution”. OTOH, if I was to take the version that does formally satisfy the task as described, it wouldn't be usable in the other task linked. Oh dear, oh dear! I think this draft task needs cleaning up, and the cleaning needs to be done by someone other than the original author with an eye to maximizing coherence and the ability to implement reasonably in many languages. –Donal Fellows 19:27, 26 July 2012 (UTC)


Hi Spoon, Donal; A quote from the Wikipedia article:

"Each permutation in the sequence that it generates differs from the previous permutation by swapping two adjacent elements of the sequence."

Do I need to make clear that the program does not have to generate using swaps - only that the above holds true? --Paddy3118 20:11, 26 July 2012 (UTC)

Yep the task description did need tidying up, which I have started.
The task was written so that it could be a precursor to a method for calculating a determinant which needs a sequence of permutations and matching sign. (The sign is generated in the recursive solution Donal, and the outputs of both Python solutions match).
Hopefully with these modifications the task should be in a fit state to be attempted in other languages. --Paddy3118 20:31, 26 July 2012 (UTC)