The goal of this challenge is to take a positive integer n
and output (in lexicographic order) all sequences \$S = [a_1, a_2, ..., a_t]\$ of distinct positive integers such that \$\max(S) = n\$.
For example, for an input n = 3
your program should output the following eleven sequences in the following order:
[
[1, 2, 3],
[1, 3],
[1, 3, 2],
[2, 1, 3],
[2, 3],
[2, 3, 1],
[3],
[3, 1],
[3, 1, 2],
[3, 2],
[3, 2, 1],
]
(In general, for an input n
, your program should output \$A001339(n-1)\$ sequences.)
This is a code-golf challenge, so the shortest code wins.
[1,n]
that includen
, is that correct? \$\endgroup\$