perl -MAlgorithm::Combinatorics=permutations -E"@a=reverse 1..14; $i=permutations([0..13]); say join' ', @a[@$_] while $_=$i->next" 14 13 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 1 2 14 13 12 11 10 9 8 7 6 5 4 2 3 1 14 13 12 11 10 9 8 7 6 5 4 2 1 3 14 13 12 11 10 9 8 7 6 5 4 1 3 2 14 13 12 11 10 9 8 7 6 5 4 1 2 3 ...