Husk, 12 bytes
S≡o ́Ṫ§oε%=▼l·
Explanation
S≡o ́Ṫ§oε%=▼l· Input is a k×ばつk array A.
l· The range [1,2..k]
o ́Ṫ Outer product with itself by this function:
Arguments are two numbers x and y.
▼ Minimum of x and y
§% modulo
= equality of x and y.
oε Is it at most 1?
S≡ Does the result have the same shape and distribution of truthy values as A?
Zgarb
- 43.2k
- 4
- 84
- 265