Skip to main content
1 of 2
Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180

Jolf, 13 bytes

ΆFi liγhj_γgi

A tranpilation of the JavaScript answer.

Explanation:

ΆFi liγhj_γgi
Ά             ternary add
 Fi            i[0],
   `li         i sliced
      γhj       γ = j + 1
         _γ     to -γ
           gi  and the last of i

Try it here!

Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180