Permutations by swapping: Difference between revisions

m
added a ;Task: and ;Related task: (bold) headers.
m (→‎{{header|Sidef}}: minor code improvements)
m (added a ;Task: and ;Related task: (bold) headers.)
Line 1:
{{task}}
 
;Task:
Generate permutations of n items in which successive permutations differ from each other by the swapping of any two items.
 
Also generate the sign of the permutation which is +1 when the permutation is generated from an even number of swaps from the initial state, and -1 for odd.
 
Show the permutations and signs of three items, in order of generation ''here''.
 
Line 13 ⟶ 17:
* [http://stackoverflow.com/a/29044942/10562 Correction to] Heap's algorithm as presented in Wikipedia and widely distributed.
 
;Related task:
;Cf.:
*   [[Matrix arithmetic]]
<br><br>