Ruby, 29 bytes
->s,n{s[0]+s[n+1...~n]+s[-1]}
Very straightforward.
~
trick stolen from Sp's answer, which saves a byte over s[n+1..-2-n]
. (It works because ~n
is -1-n
in two's-complement, and then ...
is an exclusive range.)
->s,n{s[0]+s[n+1...~n]+s[-1]}
Very straightforward.
~
trick stolen from Sp's answer, which saves a byte over s[n+1..-2-n]
. (It works because ~n
is -1-n
in two's-complement, and then ...
is an exclusive range.)