in reply to How to shuffle this AoA
Though I very much agree with hippo that the rules are quite unclear, let me take a guess: In the first counterexample, in each of the arrays only one pair of elements has been swapped from the original. In the second example, the first and third row are the same. Are you perhaps looking for something along the lines of derangements from Algorithm::Combinatorics?
$ perl -MData::Dump -MAlgorithm::Combinatorics=derangements \ -e 'dd derangements([ 2, 3, 4, 5 ])' ( [3, 2, 5, 4], [3, 4, 5, 2], [3, 5, 2, 4], [4, 2, 5, 3], [4, 5, 2, 3], [4, 5, 3, 2], [5, 2, 3, 4], [5, 4, 2, 3], [5, 4, 3, 2], )
|
|---|