Skip to main content
fix at +2, and add explanation
Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 293

APL (Dyalog Unicode), 1012 bytes

Anonymous tacit prefix function.

⊂(∨/¨⍳∊¨1=,¨⊂1∊⊢)¨⍳ 

Try it online!Try it online!

⊂()¨⍳ apply the following tacit infix function between the entire argument and each index in an array of those dimensions:

1∊⊢ is there a 1 in the index?

=, prepend a Boolean list indicating which coordinate are equal to the corresponding element of the original argument

∨/ are any true? (lit. OR reduction)

APL (Dyalog Unicode), 10 bytes

∨/¨⍳∊¨1,¨⊂ 

Try it online!

APL (Dyalog Unicode), 12 bytes

Anonymous tacit prefix function.

⊂(∨/=,1∊⊢)¨⍳ 

Try it online!

⊂()¨⍳ apply the following tacit infix function between the entire argument and each index in an array of those dimensions:

1∊⊢ is there a 1 in the index?

=, prepend a Boolean list indicating which coordinate are equal to the corresponding element of the original argument

∨/ are any true? (lit. OR reduction)

Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 293

APL (Dyalog Unicode), 10 bytes

∨/¨⍳∊¨1,¨⊂ 

Try it online!