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 Revisions

5 of 9
added 12 characters in body
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

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

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