Challenge
Given a positive integer \$n\$, output the \$n\$-dimensional pyramidal list.
Example
\$n = 1\$:
Objects arranged in a 1D pyramid (line) with side length 1 is just by itself.
So, the output is {1}
.
\$n = 2\$:
Objects arranged in a 2D pyramid (a triangle) with side length 2 would have one on the first row (cyan), and two on the second row (magenta).
Note, the first row is a 1D pyramid with side length 1 ({1}
), and the second row is a 1D pyramid with side length 2 ({1, 1}
).
So, the output is {{1}, {1, 1}}
.
\$n = 3\$:
Objects arranged in a 3D pyramid with side length 3 would have 3 layers:
- The first layer (cyan) is a 2D pyramid with side length 1. It has one row, which has one object. (
{{1}}
) - The second layer (magenta) is a 2D pyramid with side length 2; It has two rows: the first row with one object and the second row with two objects. (
{{1}, {1, 1}}
) - The third layer (yellow) is a 2D pyramid with side length 3; it has three rows: the first row with one object, second with two, and third with three. (
{{1}, {1, 1}, {1, 1, 1}}
)
So, the output is {{{1}}, {{1}, {1, 1}}, {{1}, {1, 1}, {1, 1, 1}}}
.
\$n = k\$
This is a \$k\$ dimensional pyramid with side length \$k\$. Each "layer" would be a \$k-1\$ dimensional pyramid, whose side length is its index (1-indexed).
Sample Outputs
n output
1 {1}
2 {{1},
{1, 1}}
3 {{{1}},
{{1}, {1, 1}},
{{1}, {1, 1}, {1, 1, 1}}}
4 {{{{1}}},
{{{1}}, {{1}, {1, 1}}},
{{{1}}, {{1}, {1, 1}}, {{1}, {1, 1}, {1, 1, 1}}},
{{{1}}, {{1}, {1, 1}}, {{1}, {1, 1}, {1, 1, 1}},
{{1}, {1, 1}, {1, 1, 1}, {1, 1, 1, 1}}}}
Rules
- No standard loopholes as always.
- The innermost values of your list may be anything (does not need to be consistent for all elements), as long as they are not lists.
This is code-golf, so shortest submissions in each language win!
Note: Graphics generated using Mathematica