(heavily inspired by Element of string at specified index)
Given a string s
and an integer n
representing an index in s
, output s
with the character at the n
-th position removed.
0-indexing and 1-indexing are allowed.
- For 0-indexing,
n
will be non-negative and less than the length ofs
. - For 1-indexing,
n
will be positive and less than or equal to the length ofs
.
s
will consist of printable ASCII characters only (\x20-\x7E
, or
through ~
).
Any reasonable input/output is permitted. Standard loopholes apply.
Testcases (0-indexed):
n s output
0 "abcde" "bcde"
1 "abcde" "acde"
2 "a != b" "a = b"
3 "+-*/" "+-*"
4 "1234.5" "12345"
3 "314151" "31451"
Testcases (1-indexed):
n s output
1 "abcde" "bcde"
2 "abcde" "acde"
3 "a != b" "a = b"
4 "+-*/" "+-*"
5 "1234.5" "12345"
4 "314151" "31451"
This is code-golf, so shortest answer in bytes wins.
3
,314151
->31451
. I'd assume not. \$\endgroup\$