Skip to main content
2 of 3
added 285 characters in body
ngn
  • 15.3k
  • 2
  • 43
  • 87

APL (Dyalog Classic), 24 bytes

(t-1)↓(-t←2⍴⎕)∘↑¨,\⍪⍀⍪¨⎕

Try it online!

the result is a matrix of matrices, though Dyalog's output formatting doesn't make that very obvious

input the matrix (), turn each element into a matrix on its own (⍪¨), take prefix concatenations by row (,\) and by column (⍪⍀), input n (), take the bottom right n-by-n corner from each matrix ((-t←2⍴⎕)∘↑¨), drop the first n-1 rows and columns of matrices ((t-1)↓)

ngn
  • 15.3k
  • 2
  • 43
  • 87