Skip to main content
Tweeted twitter.com/StackCodeGolf/status/905917384682242049
added 3 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

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

Input:

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

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
added 15 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

Input:

Take a list of, 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

Input:

Take a list of 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

Input:

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
added 16 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

Input:

Take a list of positive integers as input:

3 5 2 1 6

and create a matrix where the n'th column contains the vector 1:L(n) possibly, 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

Input:

Take a list of positive integers as input:

3 5 2 1 6

and create a matrix where the n'th column contains the vector 1:L(n) possibly 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

Input:

Take a list of 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
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295
Loading