Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 38 characters in body
Source Link
AZTECCO
  • 11k
  • 1
  • 17
  • 60

APL (Dyalog Unicode), 63(削除) 63 (削除ここまで) 55 bytes

{(F⍉⍵)+(F←{(⍵≡(⍴⍵1↑⍴⍵)⍴1↑⍵=(+/,⍵)∧1=+×ばつ+/1↑⍵∧/⍵})⍵}

Try it online! Try it online!

  • pretty sure it can be golfed.

  • F first construct a matrix of the same shape using the 1st row and compares it to the one passed. It also check that the first row has just one 1

    changed approach
  • we do the test to input transposed.

    F used on input + input transposed
×ばつ+/∧/⍵ ⍝ number of all 1s lines multiplied by
(+/,⍵) ⍝ total 1s 
(1↑⍴⍵)= ⍝ equal to side length?

APL (Dyalog Unicode), 63 bytes

{(F⍉⍵)+(F←{(⍵≡(⍴⍵)⍴1↑⍵)∧1=+/1↑⍵})⍵}

Try it online!

  • pretty sure it can be golfed.

  • F first construct a matrix of the same shape using the 1st row and compares it to the one passed. It also check that the first row has just one 1

  • we do the test to input transposed.

APL (Dyalog Unicode), (削除) 63 (削除ここまで) 55 bytes

{(F⍉⍵)+(F←{(1↑⍴⍵)=(+/,⍵)×ばつ+/∧/⍵})⍵}

Try it online!

  • changed approach
  • F used on input + input transposed
×ばつ+/∧/⍵ ⍝ number of all 1s lines multiplied by
(+/,⍵) ⍝ total 1s 
(1↑⍴⍵)= ⍝ equal to side length?
Source Link
AZTECCO
  • 11k
  • 1
  • 17
  • 60

APL (Dyalog Unicode), 63 bytes

{(F⍉⍵)+(F←{(⍵≡(⍴⍵)⍴1↑⍵)∧1=+/1↑⍵})⍵}

Try it online!

  • pretty sure it can be golfed.

  • F first construct a matrix of the same shape using the 1st row and compares it to the one passed. It also check that the first row has just one 1

  • we do the test to input transposed.

AltStyle によって変換されたページ (->オリジナル) /