Skip to main content
1 of 3
Razetime
  • 27.4k
  • 3
  • 29
  • 72

APL (Dyalog Unicode), 95 bytes

{p←⌊/0~⍨+/⍵⋄i←0⋄{(⍴⍵)≡+/¨1⌷¨(⍉⍵)⍵}⌽∘⍉⍣{(~⊃⌽⊖⍺)∨i=4⊣i+←1}{×≢⍵:⍵⋄,0}p∧⌿p∧/⍵}{(¯1+⌊⌿c)↓⍵↑⍨⌈⌿c←↑⍸⍵}

Try it online!

A train of two dfns which takes a matrix of 0's and 1's as argument.

Can be simplified a lot using Jonah's idea.

It simplifies the matrix like so:

#####
##### →  ####
   ##       #

rotates it to put the corner at the top left:

##
#
#
#

and then checks if the first row and first column match its shape.

Razetime
  • 27.4k
  • 3
  • 29
  • 72