Generate square sub-matrices of 1's

2

Back again, stealing another question from stackoverflow.

You are given a list of integers >= 0. Generate in order square 1-matrices where the side length is given by the list entry of the current index and fill the rest with 0s.

So given a list 2,4,1,3 print this to stdout:

1 1 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 1 1 1

Rules

  • Efficiency doesn't matter. (as long as it terminates on e.g. TIO)
  • Standard loopholes are forbidden.
  • In/Output has to adhere to the default I/O consensus.
  • This is code-golf. Shortest answer in bytes wins!

jaaq

Posted 2019-10-23T07:01:49.610

Reputation: 499

Question was closed 2019-10-23T07:08:21.270

5A nice question, but a duplicate. – xnor – 2019-10-23T07:08:32.923

Sorry, that one wouldn't pop up when I searched for duplicates. – jaaq – 2019-10-23T11:22:46.677

No answers