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

2 of 5
added 458 characters in body
Zgarb
  • 43.2k
  • 4
  • 84
  • 265

Husk, 12 bytes

S≡o ́Ṫ§oε%=▼l·

Try it online!

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

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