// output of ./demo/comb/perm-gray-rfact-demo.cc: // Description: //% Generate all permutations in minimal-change order //% via Gray code for rising factorial numbers, CAT algorithm. arg 1: 4 == n [Permutations of n elements.] default=4 0: [ . 1 2 3 ] (3, 2) [ . . . ] 3 -1 [ . 1 2 3 ] 1: [ 1 . 2 3 ] (0, 1) [ 1 . . ] 0 +1 [ 1 . 2 3 ] 2: [ 2 . 1 3 ] (0, 2) [ 1 1 . ] 1 +1 [ 1 2 . 3 ] 3: [ . 2 1 3 ] (0, 1) [ . 1 . ] 0 -1 [ . 2 1 3 ] 4: [ 1 2 . 3 ] (0, 2) [ . 2 . ] 1 +1 [ 2 . 1 3 ] 5: [ 2 1 . 3 ] (0, 1) [ 1 2 . ] 0 +1 [ 2 1 . 3 ] 6: [ 3 1 . 2 ] (0, 3) [ 1 2 1 ] 2 +1 [ 2 1 3 . ] 7: [ 1 3 . 2 ] (0, 1) [ . 2 1 ] 0 -1 [ 2 . 3 1 ] 8: [ . 3 1 2 ] (0, 2) [ . 1 1 ] 1 -1 [ . 2 3 1 ] 9: [ 3 . 1 2 ] (0, 1) [ 1 1 1 ] 0 +1 [ 1 2 3 . ] 10: [ 1 . 3 2 ] (0, 2) [ 1 . 1 ] 1 -1 [ 1 . 3 2 ] 11: [ . 1 3 2 ] (0, 1) [ . . 1 ] 0 -1 [ . 1 3 2 ] 12: [ . 2 3 1 ] (1, 3) [ . . 2 ] 2 +1 [ . 3 1 2 ] 13: [ 2 . 3 1 ] (0, 1) [ 1 . 2 ] 0 +1 [ 1 3 . 2 ] 14: [ 3 . 2 1 ] (0, 2) [ 1 1 2 ] 1 +1 [ 1 3 2 . ] 15: [ . 3 2 1 ] (0, 1) [ . 1 2 ] 0 -1 [ . 3 2 1 ] 16: [ 2 3 . 1 ] (0, 2) [ . 2 2 ] 1 +1 [ 2 3 . 1 ] 17: [ 3 2 . 1 ] (0, 1) [ 1 2 2 ] 0 +1 [ 2 3 1 . ] 18: [ 3 2 1 . ] (2, 3) [ 1 2 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