%I #6 Aug 25 2016 21:01:03
%S 1,2,1,2,1,3,3,4,1,2,2,4,1,5,3,5,4,2,6,1,3,4,7,5,1,3,2,6,8,1,2,3,4,7,
%T 6,5,6,9,2,1,7,8,5,4,3,2,8,9,4,6,7,10,5,1,3,5,1,6,10,8,11,9,2,7,3,4,7,
%U 1,9,5,6,2,12,4,8,11,10,3
%N Triangle read by rows in which row n lists the lexicographic composition of the elements of symmetric group S_n.
%e Triangle begins:
%e 1
%e 2 1
%e 2 1 3
%e 3 4 1 2
%e 2 4 1 5 3
%e 5 4 2 6 1 3
%e 4 7 5 1 3 2 6
%e 8 1 2 3 4 7 6 5
%e 6 9 2 1 7 8 5 4 3
%e 2 8 9 4 6 7 10 5 1 3
%e 5 1 6 10 8 11 9 2 7 3 4
%e 7 1 9 5 6 2 12 4 8 11 10 3
%e For the third row, the 6 permutations of 123 in lexical order are 123, 132, 213, 231, 312, and 321. Consecutively applying each permutation to 123 results in the sequence: 123, 132, 312, 123, 312, 213. The final element with commas inserted gives us the row: 2,1,3.
%o (Python)
%o from itertools import count, permutations
%o for size in count(1):
%o row = tuple(range(1, size + 1))
%o for p in permutations(range(size)):
%o row = tuple(row[i] for i in p)
%o print(row)
%K nonn,tabl
%O 1,2
%A _David Nickerson_, Jul 15 2016