Input:
Challenge:
Take a list, L containing positive integers as input:
3 5 2 1 6
and create a matrix where the n'th column contains the vector 1:L(n), where shorter rows are padded with zeros.
Test cases:
3 5 2 1 6
-----------------
1 1 1 1 1
2 2 2 0 2
3 3 0 0 3
0 4 0 0 4
0 5 0 0 5
0 0 0 0 6
1
-
1
1 2 3 4 3 2 1
-------------------------
1 1 1 1 1 1 1
0 2 2 2 2 2 0
0 0 3 3 3 0 0
0 0 0 4 0 0 0
Rules:
- Optional input and output formats
- List of lists is an acceptable output format
- The matrix must be as small as possible (you may not pad it with more zeros than needed)
- Shortest code in each language wins
- Explanations are highly encouraged