Skip to main content
added 278 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 5 bytes

Z⁹Ƥ⁺€

Uses the 4D output format. For 3D, append a for 6 bytes.

Try it online!

How it works

Z⁹Ƥ⁺€  Main link. Left argument: M (matrix). Right argument: n (integer)

 ⁹Ƥ    Apply the link to the left to all infixes of length n.
Z        Zip the rows of the infix, transposing rows and columns.
   ⁺€  Map Z⁹Ƥ over all results.

Jelly, 5 bytes

Z⁹Ƥ⁺€

Uses the 4D output format. For 3D, append a for 6 bytes.

Try it online!

Jelly, 5 bytes

Z⁹Ƥ⁺€

Uses the 4D output format. For 3D, append a for 6 bytes.

Try it online!

How it works

Z⁹Ƥ⁺€  Main link. Left argument: M (matrix). Right argument: n (integer)

 ⁹Ƥ    Apply the link to the left to all infixes of length n.
Z        Zip the rows of the infix, transposing rows and columns.
   ⁺€  Map Z⁹Ƥ over all results.
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 5 bytes

Z⁹Ƥ⁺€

Uses the 4D output format. For 3D, append a for 6 bytes.

Try it online!