Skip to main content
3 of 4
edited body
ngn
  • 15.3k
  • 2
  • 43
  • 87

APL (Dyalog Classic), 27 bytes

{(⍺⊥⍺|(⍺⊤⍵)-⊢)¨1-1↓4⌽,⍳3 3}

Try it online!

ngn
  • 15.3k
  • 2
  • 43
  • 87