Given a positive integer n
, do the following (and output every stage):
- start with a list containing
n
copies ofn
. - do the following
n
times: - at the
i
th step, gradually decrement thei
th entry of the list until it reachesi
So, for example, if the given n
is 4
, then you start with [4,4,4,4]
, and then at the first step you have [3,4,4,4]
, [2,4,4,4]
, [1,4,4,4]
. At the second step, you have [1,3,4,4]
, [1,2,4,4]
. At the third step you have [1,2,3,4]
. Nothing is done on the fourth step.
So your output is [[4,4,4,4],[3,4,4,4],[2,4,4,4],[1,4,4,4],[1,3,4,4],[1,2,4,4],[1,2,3,4]]
.
Any reasonable input/output format is permitted.
Standard loopholes apply. This is code-golf: the answer with the smallest byte-count wins.
i
th is always 1-indexed. \$\endgroup\$