MATL, (削除) 9 (削除ここまで) 8 bytes
tY*zUGn=
Inputs a matrix. Gives 1 or 0 for Hadamard or non-Hadamard, respectively.
Try it online! Or verify all test cases
How it works
t % Implicit input: matrix M, of size n, with 1 or −1 entries. Duplicate
Y* % Matrix product, M*M. This is a scalar matrix if and only if M is Hadamard
z % Number of non-zeros. Gives n if and only if M is Hadamard
U % Square
G % Push input again
n % Number of entries. Gives n^2
= % Equal? Implicit display
Luis Mendo
- 106.7k
- 10
- 139
- 382