Permutations: Difference between revisions

Content added Content deleted
Line 1,517: Line 1,517:
3 2 1</pre>
3 2 1</pre>


== Alternate solution ==
=== Alternate solution ===


Instead of looking up unused values, this program starts from [1, ..., n] and does only swaps, hence the array always represents a valid permutation.
Instead of looking up unused values, this program starts from [1, ..., n] and does only swaps, hence the array always represents a valid permutation.