APL (Dyalog Unicode), 63(削除) 63 (削除ここまで) 55 bytes
{(F⍉⍵)+(F←{(⍵≡(⍴⍵1↑⍴⍵)⍴1↑⍵=(+/,⍵)∧1=+×ばつ+/1↑⍵∧/⍵})⍵}
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 approachwe 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↑⍵})⍵}
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↑⍴⍵)=(+/,⍵)×ばつ+/∧/⍵})⍵}
- changed approach
- 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↑⍵})⍵}
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.