APL (Dyalog Unicode), 22 bytes
∊({⍵+⍳≢⍵}¨⊢⊆⍨⊢+1+∘|⌊/)
I was hoping for an extremely short answer using ⊆
, but it doesn't allow negative numbers (on the left). Explanation coming.
∊({⍵+⍳≢⍵}¨⊢⊆⍨⊢+1+∘|⌊/)
I was hoping for an extremely short answer using ⊆
, but it doesn't allow negative numbers (on the left). Explanation coming.