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 Answer

explain
Source Link
Adám
  • 31.8k
  • 4
  • 131
  • 292

APL (dzaima/APL), 20 bytes

⊢⌿⍥,⍨1∊ ̈⍳∘⍴∊ ̈ ̈∘⊂1, ̈⍴

Try it online!

shape (length along each dimension) of the array

1, ̈ prepend 1 to each

...∊ ̈ ̈∘⊂ for each of each of the following, is it a member of the corresponding element of that?

⍳∘⍴ the indices of an array of the shape of the argument

1∊ ̈ for each of those, is 1 a member?

...⌿⍥,⍨ use that flattened, to filter the flattened...

argument

APL (dzaima/APL), 20 bytes

⊢⌿⍥,⍨1∊ ̈⍳∘⍴∊ ̈ ̈∘⊂1, ̈⍴

Try it online!

APL (dzaima/APL), 20 bytes

⊢⌿⍥,⍨1∊ ̈⍳∘⍴∊ ̈ ̈∘⊂1, ̈⍴

Try it online!

shape (length along each dimension) of the array

1, ̈ prepend 1 to each

...∊ ̈ ̈∘⊂ for each of each of the following, is it a member of the corresponding element of that?

⍳∘⍴ the indices of an array of the shape of the argument

1∊ ̈ for each of those, is 1 a member?

...⌿⍥,⍨ use that flattened, to filter the flattened...

argument

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

APL (dzaima/APL), 20 bytes

⊢⌿⍥,⍨1∊ ̈⍳∘⍴∊ ̈ ̈∘⊂1, ̈⍴

Try it online!

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