Skip to main content
deleted 2 characters in body
Source Link
Razetime
  • 27.4k
  • 3
  • 29
  • 72

APL (Dyalog Unicode), 105104 bytes

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

Try it online!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.

APL (Dyalog Unicode), 105 bytes

{p←⌊/0~⍨+/⍵⋄i←0⋄{(~×/1=,⍵)∧(⍴⍵)≡+/¨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.

APL (Dyalog Unicode), 104 bytes

{i←0⋄{(~×/1=,⍵)∧(⍴⍵)≡+/¨1⌷¨(⍉⍵)⍵}⌽∘⍉⍣{(~⊃⌽⊖⍺)∨i=4⊣i+←1}{×≢⍵:⍵⋄,0}p∧⌿⍵∧/⍨p←⌊/0~⍨+/⍵}{(¯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.

added 22 characters in body
Source Link
Razetime
  • 27.4k
  • 3
  • 29
  • 72

APL (Dyalog Unicode), 95105 bytes

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

Try it online!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.

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.

APL (Dyalog Unicode), 105 bytes

{p←⌊/0~⍨+/⍵⋄i←0⋄{(~×/1=,⍵)∧(⍴⍵)≡+/¨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.

Source Link
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.