Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Remove character at specified index

(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 of s.
  • For 1-indexing, n will be positive and less than or equal to the length of s.

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 , so shortest answer in bytes wins.

Answer*

Draft saved
Draft discarded
Cancel
3
  • \$\begingroup\$ Another fun solution that's almost identical is jD@"gox \$\endgroup\$ Commented May 19, 2017 at 19:08
  • \$\begingroup\$ Flagging -> Closing -> Duplicate of codegolf.stackexchange.com/a/121581/61563 :P kidding, but they are remarkably similar. \$\endgroup\$ Commented May 20, 2017 at 20:44
  • \$\begingroup\$ they are! Is there any prize for getting down to 7 characters first? :-P \$\endgroup\$ Commented May 22, 2017 at 7:58

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