# [Perl 6], 82 bytes

*-2 bytes thanks to Jo King*

<!-- language-all: lang-perl6 -->

    ->\n{([-] map {$/=[^n];:10[map {|splice $/,$_,1},[R,] .polymod(1..n-2)]},n+1,n)/9}

[Try it online!][TIO-jocsbs1n]

[Perl 6]: https://github.com/nxadm/rakudo-pkg
[TIO-jocsbs1n]: https://tio.run/##LcjfCoIwFIDxVzkXIxwd3Y7rDxb2EN2uJZIKwZxDr8T27Culmx98n29He4r9DLsOypjeHm5JdGqgrz0sTJT66cz1QlJv4zN5@361wASyCimgvqOBzA927ocmoSxzac5NQLcndFwUIU71DF3CKg7dMEKuEIgKhPPKUaqfB6nWICk3/sr4BQ "Perl 6 – Try It Online"

0-indexed. Doesn't enumerate all permutations. Should theoretically work for all n, but bails out for n > 65536 with "Too many arguments in flattening array".

The following **80 byte** version works for n up to 98!-2 and is a lot faster:

    {([-] map {$/=[^99];:10[map {|splice $/,$_,1},[R,] .polymod(1..97)]},$_+1,$_)/9}

[Try it online!][TIO-jocsd0tj]

[TIO-jocsd0tj]: https://tio.run/##NY1BDoIwFESv8hfEFC3QTxWohku4baohQhOTNjSwapCz10J0815mZjFumEwVrIeDhjYsRGYKbOdgSYpWPoRQtysyuTef2Zn3a4CkoMmT4krlnSrI3Wi8HXuCeS7qVK1xPGFEWog1zJ0HTWIAPU5QcgqIgkK94cJ45JnxLfCqbOpoZGzHj39FE3lUsJ00aVaGLw "Perl 6 – Try It Online"

The following **53 byte** version should theoretically work for all n, but bails out for n >= 20 with "refusing to permutate more than 20 elements".

    {[-](map {:10[$_]},permutations(1..$_+1)[$_,$_-1])/9}

[Try it online!][TIO-jocswrfh]

[TIO-jocswrfh]: https://tio.run/##K0gtyjH7n1upoJamYPu/Olo3ViM3sUCh2srQIFolPrZWpyC1KLe0JLEkMz@vWMNQT08lXttQEyiloxKvaxirqW9Z@784sVIhTUMlXlMhLb9IAajGyOA/AA "Perl 6 – Try It Online"