| Bytes | Lang | Time | Link |
|---|---|---|---|
| 011 | APLNARS | 250501T090624Z | Rosario |
| 034 | Tcl | 180929T212108Z | sergiol |
| 001 | Vyxal | 220116T004914Z | lyxal |
| 001 | Thunno 2 | 230610T133649Z | The Thon |
| 026 | Befunge93 | 220114T070929Z | quintopi |
| 010 | Factor | 220114T061844Z | chunes |
| 048 | Runic | 180929T194551Z | Draco18s |
| 030 | JavaScript | 180929T010244Z | guest271 |
| 045 | MBASIC | 180924T153244Z | wooshiny |
| 001 | q | 180920T212844Z | Thaufeki |
| 043 | PHP | 180924T160423Z | Francisc |
| 004 | 05AB1E | 180921T065013Z | Kevin Cr |
| 017 | Stacked | 180924T145947Z | Conor O& |
| 013 | Attache | 180924T142842Z | Conor O& |
| 040 | R | 180922T091507Z | J.Doe |
| 045 | Forth gforth | 180921T202925Z | reffu |
| 038 | Lua | 180920T205930Z | Marcio M |
| 012 | Backhand | 180921T032631Z | Jo King |
| 015 | Haskell | 180920T194210Z | H.PWiz |
| 012 | Rebol | 180921T010430Z | HappySpo |
| 009 | ><> | 180921T004949Z | Jo King |
| 028 | TSQL | 180920T201956Z | BradC |
| 049 | QBasic | 180203T062203Z | DLosc |
| 034 | Cubically | 170809T220706Z | TehPers |
| 020 | Excel | 170809T094532Z | Wernisch |
| 005 | APL Dyalog | 170809T063951Z | Adá |
| 047 | R | 170520T103239Z | user2390 |
| 023 | Braingolf | 170608T090432Z | Mayube |
| 019 | C# | 170519T135345Z | TheLetha |
| 002 | Japt | 170519T140758Z | Luke |
| 022 | Bash | 170519T210631Z | DrnglVrg |
| 024 | ><> | 170524T052018Z | Not a tr |
| 056 | Batch | 170523T114549Z | Neil |
| 041 | PHP | 170523T071230Z | M.E |
| 029 | Excel | 170520T123159Z | pajonk |
| 041 | Java 8 | 170519T152829Z | TheLetha |
| 030 | REXX 30 Bytes | 170520T215929Z | theblitz |
| 050 | C | 170520T190717Z | MD XF |
| 036 | shortC | 170520T191034Z | MD XF |
| 023 | SmileBASIC 3 | 170520T182830Z | snail_ |
| 045 | R | 170520T152352Z | Sven Hoh |
| 006 | sed | 170520T092708Z | gdahlm |
| 025 | Befunge98 | 170519T212023Z | ovs |
| 086 | Swift | 170520T042427Z | Mr. Xcod |
| 014 | brainfuck | 170519T212238Z | eush77 |
| 018 | Mathematica | 170519T140158Z | ZaMoC |
| 012 | Alice | 170519T140820Z | Martin E |
| 008 | J | 170519T192426Z | miles |
| 115 | Chip | 170519T191112Z | Phlarx |
| 007 | vim | 170519T135523Z | Doorknob |
| 044 | C gcc | 170519T145302Z | Yk Chees |
| 003 | Jelly | 170519T181904Z | Jonathan |
| 024 | Haskell | 170519T135947Z | Sgt. Dog |
| 039 | BrainFlak | 170519T171348Z | DJMcMayh |
| 029 | Retina | 170519T170549Z | eush77 |
| 031 | JS ES6 | 170519T135437Z | user5882 |
| 048 | Javascript ES6 | 170519T155451Z | user6953 |
| 025 | GCC c function | 170519T161301Z | Digital |
| 016 | Ruby | 170519T154622Z | Alex |
| 037 | Braingolf | 170519T152126Z | Mayube |
| 028 | QBIC | 170519T150101Z | steenber |
| 001 | K Kona | 170519T151551Z | Simon Ma |
| 003 | V | 170519T152005Z | DJMcMayh |
| 039 | Java 8 | 170519T145353Z | Kevin Cr |
| 042 | PHP | 170519T145043Z | Jör |
| 037 | Lua | 170519T144900Z | Felipe N |
| 050 | Go | 170519T144630Z | totallyh |
| 007 | Vim | 170519T143828Z | jmriego |
| 033 | JavaScript ES6 | 170519T140310Z | Shaggy |
| 025 | PowerShell | 170519T142927Z | colsw |
| 003 | MATL | 170519T140539Z | Luis Men |
| 003 | Pyth | 170519T141537Z | Erik the |
| 002 | Japt | 170519T140657Z | Tom |
| 006 | 05AB1E | 170519T140441Z | Emigna |
| 005 | 05AB1E | 170519T140307Z | Riley |
| 004 | Jelly | 170519T135758Z | fireflam |
| 019 | Perl 5 | 170519T135834Z | Dada |
| 004 | CJam | 170519T135555Z | Business |
| 024 | Python 3 | 170519T135351Z | Leaky Nu |
APL(NARS), 11 chars
{⍵[⍺∼⍨⍳≢⍵]}
All 1 indexed... test:
1{⍵[⍺∼⍨⍳≢⍵]}1 2 3 4 5 8
2 3 4 5 8
Befunge-93, 26 bytes
&>1# -#,:#~_~~>:# 1#~+#,_@
1-indexed, does NOT require a null byte at the end of the string because that's lame. However, if you really want to get all "let's screw with the input format to make the code shorter", here is one that saves 3 bytes by assuming a null terminator:
&>1# -#,:#~_~~>:#~ #,_@
Runic, 48 bytes
/~~{ R:1(?\~@
/3{\?)0:\S{-1/
\s3s}}1-U}:irui<
Not all test cases work at the moment: a few (more) flaws discovered in the parser.
- Numbers are read as numerical values and don't
unconcatenate (I need to call.ToString()on the popped object, then split the result into a char array; this will match intended spec of "doing operations to the best of the execution context's ability with the given stack values) - Spaces (and other white space) are input value separators (I need to readd the control character demarcation; got lost in the previous attempts to fix the next issue). After fixing inputs such as
a != bwould need to be passed asa\ !=\ b - Input needs a trailing newline (have not discovered a fix to this yet)
Other test cases work (and are considered 0-indexed).
Explanation
Program starts in the lower right (red), reads a string, unconcatenates it, reverse it (so the first character is at the top of the stack; behavior is so that u followed by q results in concatenation in the desired order, and q works the way it does because >'a'bq, >`ab`q, and >"ab" should all have the same result). Then the program reads the integer value and assumes (per question spec) that it is in the range [0,L), values above this range will simply loop (effective %). This value is duplicated and stored at the bottom of the stack for later.
The lower left portion (yellow) is the section responsible for shifting the string around on the stack N times, where N is the input value. The 3s3s portion rotates the top 2 items on the stack below the 3rd (which results in the front-most character in the string being rotated to the end without affecting the positions of the two counters with the next two } rotates). It exits this branch along the top (green), heading right and popping 2 values (the loop counter and then the character to discard) and rotating the saved input value back to the top.
The top right (blue) then loops the remaining characters back into place in reverse, exiting the loop (purple) towards the @ which discards the remaining loop counter and prints the stack top to bottom.
Picture has a mistake, along the bottom are some stack manipulators, }}}{ and in typing up this post I noticed that }{ cancels out and saves 3 bytes.
MBASIC, 46 45 bytes
1 INPUT N,S$:PRINT LEFT$(S$,N-1);MID$(S$,N+1)
Just slamming substrings together, 1-indexed.
Output:
? 4,314151
31451
? 5,1234.5
12345
? 4,+-*/
+-*
? 3,a != b
a = b
? 2,abcde
acde
? 1,abcde
bcde
PHP, 43 Bytes
run as pipe.
Code
<?=strtr(($s=$argv)[0],[$s[0][$s[1]]=>""]);
Explanation
<?=strtr(($s=$argv)[0], # Set a shorter name for the $argv arguments var
[$s[0][$s[1]]=>""]); # Replace for "" in the position
05AB1E, 4 bytes
IõIǝ
Try it online or verify all test cases.
or alternatively
õŠŠǝ
Try it online or verify all test cases.
Explanation:
I # Take the first string input
õ # Push an empty string
I # Take the second index-integer input
ǝ # Replace the character at the given index with the empty string
õ # Push an empty string
ŠŠ # Triple-swap twice; a,b,c → c,a,b → b,c,a (implicitly using the two inputs)
# (`c` is the empty string here, `a` and `b` the input)
ǝ # Replace the character at the given index with the empty string
Stacked, 17 bytes
{%y:0\#'..x-keep}
Explanation
{%y:0\#'..x-keep} anonymous lambda, takes input on the stack
{% } parameters: x, y
y: push y twice [y, y]
0\ push 0 beneath [y, 0, y]
#' push size of TOS [y, 0, size(y)]
.. range [y, range(0, size(y))]
x- subtract x from this [y, range(0, size(y)) - x]
(thus x-x = 0)
keep keep respective chars [the answer]
this removes the character at the `x`th index
Attache, 13 bytes
{_[0:#_^^_2]}
Explanation
{_[0:#_^^_2]}
{ } anonymous lambda (_ = 1st argument, _2 = 2nd argument)
0:#_ range from 0 to the length of _
^^_2 ...without the 2nd argument
_[ ] obtain characters from _ using that range
R, 40 bytes
Just goes to show the variety of ways, none of which particularly compact, you can fiddle with strings in R.
function(s,n)intToUtf8(utf8ToInt(s)[-n])
Forth (gforth), 45 bytes
: f tuck - 1- -rot 2dup type + 1+ swap type ;
0-indexed, n should be on top of the stack
Explanation
Prints the string up to the given character, then prints the remainder of the string after the given character
Code Explanation
\ since a lot of stack manipulation is happening, I will be including a listing of the
\ stack after each step. s = string address, g = length of string, n = char to remove
: f \ starts a new word definition | s g n
tuck - \ store a copy of n, then get the length of the end of the string | s n g-n
1- \ subtract 1 from the length of the end ( to not output junk) | s n g-n-1
-rot \ move the end-string length to the back of the stack | g-n-1 s n
2dup type \ duplicate the address and length of the first output, then print | g-n-1 s n
+ 1+ \ get the starting address for the second output | g-n-1 s+n+1
swap type \ swap to get in proper order, then print |
; \ end word definition |
Lua, 51 38 bytes
Lowered to 38 bytes thanks to Jo King
x,y=...print(y:sub(1,x-1)..y:sub(x+1))
Just like everything else in Lua this is 1-indexed.
Explanation
Lua uses a table called arg to store arguments and the function sub() returns a substring of the string passed.
This is my first code golf entry, please be nice :)
Haskell, 15 bytes
This requires the recently released GHC 8.4.1 (or higher). Now <>, as a function on Semigroups, is in Prelude. It is particularly useful on the function Semigroup
take<>drop.succ
Try it online!
Since tio is using an older bersion of GHC, I've imported <> in the header.
Rebol, Red - 12 bytes
remove at s n
><>, 9 bytes
i$:&?o&1-
Takes in the number via the -v flag and the string through STDIN. This is 0 indexed and ends with an error. You can add 5 bytes to avoid the error.
Explanation:
i Get inputted character
$ Swap and bring counter to the top
:& Store a copy in the register
?o If the counter is not zero, print the character
&1- Restore and decrement the counter
T-SQL, 28 bytes
SELECT STUFF(s,n,1,'')FROM t
Input is taken via a pre-existing table t with integer n and string s, per our IO standards.
I'm assuming n is 1-based, so I can pass it straight into the SQL Stuff function. STUFF inserts or replaces the characters at the given location, and in my case I'm replacing a single character with a blank.
QBasic, 49 bytes
Uses 1-indexing.
INPUT n
LINE INPUT s$
?LEFT$(s$,n-1)+MID$(s$,n+1)
Reads a number and a string, and then prints the leftmost n-1 characters of the string plus everything from index n+1 to the end of the string.
Cubically, 46 56 34 bytes
R3D1R1$:7~?6{(~@7-0)6}~(~-0=7&6@7)
(0-based index)
Try it online! You must change &6 to ?6& on TIO due to a bug in the interpreter.
How it works
R3D1R1$:7~?6{(~@7-0)6}~(~-0=7&6@7)
R3D1R1 Set the top face to 1
$ Get next numeric input
:7 Set notepad to input
~ Read (skip) next character (space)
?6{ } If notepad is nonzero
( )6 While notepad is nonzero
~@7 Print next inputted character
-0 Subtract 1 from notepad
~ Read (skip) next character
( ) Loop indefinitely
~ Get next character
-0=7&6 Exit program if input is -1 (EOF)
@7 Output the input
Excel, 20 bytes
Different approach from previous Excel answer.
1-indexed n in A1.
Text in B1.
=REPLACE(B1,A1,1,"")
APL (Dyalog), 5 bytes
Zero-indexed. Takes index n as left argument and string s as right argument.
↑,1↓↓
↑ n characters from s
, followed by
1↓ one character dropped from
↓ n characters dropped from s
R, 48 47 bytes
(1 byte saved through use of el() thanks to Giuseppe)
function(s,n)cat(el(strsplit(s,""))[-n],sep="")
Split the string into its individual characters, remove the nth and then concatenate again.
There may well be a better solution, strsplit() is quite unwieldy as it returns a list.
C#, 20 19 bytes
s=>n=>s.Remove(n,1)
Bash, 83 24 22 bytes
echo ${1::$2-1}${1:$2}
24 bytes answer given by Digital Trauma
-2 bytes, quotation marks not needed
My first GodeGolf answer, any feedback is apreciated
><>, 24 bytes
i:0(?v$1-:}?!~{
;?(3l<o{
Try it online, or at the fish playground
Takes the string as input from STDIN, and assumes the number for the index is already on the stack; outputs to STDOUT. It's 1-indexed.
The fish reads the string one character at a time, except it forgets the nth one after it reads it. It then prints the stack (in reverse) until there are only two (junk) things left.
Batch, 56 bytes
@set/ps=
@set/ai=%1+1
@call echo %%s:~0,%1%%%%s:~%i%%%
Takes n 0-indexed as a command-line parameter and reads s from STDIN.
Excel, 29 bytes
=LEFT(A1,A2)&MID(A1,A2+2,9^9)
Assumes input in cells A1 (string) and A2 (integer, 0-indexing).
Takes the left part of the string with LEFT and the right part - actually a substring starting on position A2+2 and 9^9 characters long (which is more then the max string length in one cell: 32,767 characters).
Java 8, 45 41 bytes
s->n->new StringBuffer(s).deleteCharAt(n)
Saved 4 bytes thanks to @OlivierGrégoire
My first code golf answer in something other than C#, even if it isn't the shortest for Java yet.
REXX 30 Bytes
parse arg p x
say delstr(x,p,1)
C, 57 50 bytes
#define f(s,n)for(i=n;s[i];i++)s[i]=s[i+1];puts(s)
0-indexed, naturally. I call this macro with:
int main(int argc, char **argv)
{
if (argc != 3)
return;
f(argv[1],atoi(argv[2]));
}
shortC, 36 bytes
Df(s,n)Oi=n;s[i];i++)s[i]=s[i+1];Js)
See my plain C answer for how to call the macro.
SmileBASIC 3, 23 bytes
We have character indexing, why not use it? Set a character index to the empty string to delete it.
Defines a command A which prints the output. Uses 0-indexing.
DEF A S,N
S[N]="
?S
END
R, 45 bytes
pryr::f(sub(paste0("(.{",n-1,"})."),"\\1",s))
(s)ed - 6 bytes
1-based indexing.
s/.//n
Explanation:
s # substitute command.
/./ # match any single char.
// # substitution is empty.
n # Only match the 'n'th occurrence in a line.
Befunge-98, 35 27 25 bytes
-4 bytes thanks to @eush77
&#;1-:!#v_~,;
_@#:~;#~<;,
1-indexed, note that the input has a trailing null-byte.
Swift - 86 bytes (0-indexed)
func l(s:String,n:Int){var a=s;a.remove(at:a.index(a.startIndex,offsetBy:n));print(a)}
Function that can be used as l(s:"abcdefg",n:3)
Swift - 120 bytes
Since I thought the above is quite boring, I came up with another solution:
func l(s:String,n:Int){let b=s.startIndex;print(s[b...s.index(b,offsetBy:n-1)]+s[s.index(b,offsetBy:n+1)..<s.endIndex])}
Works as the one below, it's just more interesting.
brainfuck, 14 bytes
,[>,.<-],,[.,]
Reads zero-based one-byte index immediately followed by the string.
Mathematica, 18 bytes
1-indexed
#2~StringDrop~{#}&
input
[1, "abcde"]
thanks Martin Ender
Alice, 13 12 bytes
Thanks to Leo for saving 1 byte.
/oI\!e]&
@ q
First line of the input is the string, second line is the 0-based index.
Explanation
/ Reflect to SE. Switch to Ordinal. While in Ordinal mode, the IP bounces
diagonally up and down through the code.
I Read the first line of input (the string).
! Store the string on the tape, which writes the characters' code points to
consecutive cells (the tape is initialised to all -1s).
] Move the tape head right. This moves it by an entire string, i.e. to the
cell after the -1 that terminates the current string.
The IP bounces off the bottom right corner and turns around.
] Move the tape head right by another cell.
! Store an implicit empty string on the tape, does nothing. It's actually
important that we moved the tape head before this, because otherwise it
would override the first input code point with a -1.
I Read the second line of input (the index) as a string.
/ Reflect to W. Switch to Cardinal.
The IP wraps around to the last column.
&] Implicitly convert the first input to the integer value it contains
(the index) and move the tape head that many cells to the right, i.e.
onto the character we want to delete. Note that Ordinal and Cardinal mode
have two independent tape heads on the same tape, so the Cardinal tape
head is still on the first cell of the string input before we do this.
e! Store a -1 in the cell we want to delete.
\ Reflect to SW. Switch to Ordinal.
q Push the entire tape contents as a single string. This basically takes
all cells which hold valid code points from left to right on the tape
and concatenates the corresponding characters into a single string. Since
we wrote a -1 (which is not a valid code point) over the target character,
this will simply push the entire input string without that character.
o Output the result.
@ Terminate the program.
J, 8 bytes
{.,1}.}.
Uses zero-based indexing.
Explanation
{.,1}.}. Input: integer n (LHS), string s (RHS)
}. Drop the first n chars of s
1}. Drop one char from that
{. Take the first n chars of s
, Join them
Chip, 115 bytes
*Z~S
,x.z.
`@z\{Aa
,x.|*
`@z\{Bb
,x.|
`@z\{Cc
,x.|*
`@z\{Dd
,x.|
`@z\{Ee
,x.|*
`@z\{Ff
,x.|
`@z\{Gg
,x.|*
`@z\{H
S
The first byte of input is a 0-based index, the remainder is the string to process: \x02abcde.
Try it online!
In this TIO, a newline character is the index, which means an index of 0x0a = 10.
Test cases!
These use hex input + printf to make it clearer what's happening.
How does it work?
*Z~S
This suppresses output on the first byte, because we don't want to print the index. That'd be silly.
Aa, Bb, Cc, etc.
These relay the input to the output for every byte, unless suppressed. Note that the h is missing, this is because we never need to output something with the high bit set.
,x.
`@z\{D
This is the real meat of it all. There are eight of these, one for each bit of the index (a one-byte index means that indexes are not able to be specified above 255). This reads in the index on the first cycle only with switches (\). The index bits have been flipped with an xor gate ({), which is almost negation. Then, for each character of the string, this value is incremented via some half-adders (@). When this value is incremented from 0xff to 0x00, it uses the carry from the high bit to suppress output (S) for that character, effectively removing it from the string.
vim, 10 7
DgJ@"|x
Takes 1-indexed input in the following format:
2
abcde
D delete the number on the first line into register "
gJ remove the newline while preserving whitespace on line 2
@" run the " register as a macro - input is used as a count for...
| the "go to nth column" command
x delete the character at the cursor
Thanks to @DJMcMayhem for 3 bytes!
C (gcc) - 45 44 bytes
-1 Thanks to @Niel !
f(s,n)char*s;{for(;*s;++s)n--&&putchar(*s);}
alternative, 45 bytes :
g(s,n)char*s;{s[n++]=0;printf("%s%s",s,s+n);}
Jelly, 3 bytes
Ṭœp
A full program taking the (1-based) index and the string (in that order) and printing the result.
As a dyadic function it returns a list of the two parts.
In fact the index may be a list of n indices, in which case it returns a list of the n-1 parts.
Try it online!, or see a test suite.
How?
Ṭœp - Main link: number i, string s e.g. "fish 'n chips", 6
Ṭ - untruth - get a list with 1s at the indexes of i 000001 <-- i.e. [0,0,0,0,0,1]
œp - partition s at truthy indexes without borders ["fish ","n chips"]
- implicit print fish n chips
As an example of using multiple indexes:
"fish and chips", [6,8]
Ṭ 00000101 <- i.e. [0,0,0,0,0,1,0,1]
œp ["fish ","n"," chips"]
fish n chips
Haskell, 28 24 Bytes
-4 byte thanks to Laikoni, this version is 1-indexed.
s#n=take(n-1)s++drop n s
Old answer:
f(s:t)0=t;f(s:t)n=s:f t(n-1)
A simple recursive function that takes the value, it's 0-indexed.
My first time code-golfing so maybe it's not the optimal solution. Oh well.
Brain-Flak, 39 bytes
{({}<({}<>)<>>[()])}{}{}<>{({}<>)<>}<>
This has a one byte penalty for the -c flag which enables ASCII input and output. This takes the first parameter as a character code, which OP has allowed.
So the input is
0x01abcde
This uses zero indexing. Unfortunately, TIO doesn't allow null bytes in input, but this works locally so it's not an issue.
Retina, 29 bytes
1`\d+
$*
+`( +) (.)
$2$1
.
The index and the string are on the same line separated by one tab. The index is zero-based.
JS (ES6), 41 32 31 bytes
y=>i=>y.slice(0,i++)+y.slice(i)
Based on this. Takes input through currying, first is string, second is index.
-9 thanks to @JohanKarlsson
-1 thanks to @ETHproductions
Javascript (ES6), 48 bytes
x=>i=>x.substring(0,i-1)+x.substring(i,x.length)
Or this (55 bytes)
n=[],x=>i=>x.split``.forEach((_,i)=>i==x?0:n.push(_))
GCC c function, 25
1-based indexing.
f(n,s){strcpy(s-1,s+=n);}
Plenty of undefined behavior here so watch out for stray velociraptors:
- The
strcpy()man page says If copying takes place between objects that overlap, the behavior is undefined. Here there clearly is overlap of the src and dest strings, but it seems to work, so either glibc is more careful or I got lucky. - The answer is reliant on the fact that the
s+=nhappens before thes-1. The c standard gives no such guarantees, and in fact calls this out as undefined behaviour. Again, it seems to work as required with the gcc compiler on x86_64 Linux.
Braingolf, 38 37 bytes
VVR<lMMv.M2+-[R<vv]R$_v.?1-[R<v]|R&@;
0-based index
As always with Braingolf, the TIO link includes the entire Python3 parser. The code is the 2nd argument, the index is the 3rd argument, and the string is the 4th argument.
QBIC, 28 bytes
B=@ `+B?_t_s;,:|+_sB,a+2,_lB
This is an adaptation of my Substring Subtraction answer.
Explanation:
B=@ `+B Prepend a space to the input string
? PRINT
_t a trimmed version (drops the space again)
_s SUBSTRING
;,:| Read B$ from cmd line, read n from cmd line
SUBSTRING with a stirng and a positive N takes chars 1-N from the left.
+_sB Plus a second substring
,a+2 Starting behind the removee-index
,_lB taking all the remaining characters
This could go all the way down to 22 bytes if I didn't need that hacky space prepended. Time to change Substring-behaviour for this use-case...
?_s;,:-1|+_sA,a+1,_lA
K (Kona), 1 byte
_
Gotta love builtins. 0-based indexing. Usage:
k)"abcdef" _ 3
"abcef"
Java 8, 39 bytes
s->n->s.substring(0,n)+s.substring(n+1)
Java 7, 67 bytes
String c(int n,String s){return s.substring(0,n)+s.substring(n+1);}
Go, 50 bytes
1-indexed because we're all human, I think.
func f(s string,n int)string{return s[:n-1]+s[n:]}
Vim, 7 bytes
jDk@"|x
How it works:
It expects two lines; one with the string and one with the number.
- Go to line two, copy the number into register
- Go to first line and then go to column in the register with @"|
- Delete the character under the cursor
JavaScript (ES6), 39 34 33 bytes
n=>s=>s.replace(/./g,c=>n--?c:"")
56 bytes saved thanks to Arnauld.
PowerShell, 25 Bytes
3 Options, all the exact same bytecount.
$a,$b=$args;$a|% *ve $b 1
$args[1]|% *ve $args[0] 1
param($a,$b)$a|% *ve $b 1
calls .Remove on the string, using the number as an arg.
MATL, 3 bytes
&)&
Uses 1-based indexing.
Try it online! Or verify all test cases.
Explanation
& % Specify secondary default number of inputs/outputs for next function
) % Implicitly input string and number. Index: with & it pushes the char
% defined by the index and the rest of the string
& % Specify secondary default number of inputs/outputs for next function
% Implicitly display (XD): with & it only displays the top of the stack
In the modified version with all the test cases, the code is within an infinite loop `...T until no input is found. At the end of each iteration the display function (XD) is explicitly called, and the stack is cleared (x) to ready it for the next iteration.
05AB1E, 6 bytes
vNÊiy?
Explanation
v # for each element, index (y,N) in input1
NÊi # if N is not equal to input2
y? # print y
05AB1E, 5 bytes
ā²ÊÏJ
ā # push range(1, len(input string) + 1)
²Ê # Check each for != to input index
Ï # Keep characters from input where this array is 1
J # Join
Jelly, 4 bytes
Jḟị³
Explanation
Jḟị³
J - all indices of the input string
ḟ - except for the input index
ị - return the elements at those indices
³ - of the input string
Perl 5, 19 bytes
18 bytes of code + -p flag
substr($_,<>,1)=""
substr($_,<>,1) returns 1 character at index <> (the 2nd input) in the string $_ (the input). And ="" changes it to "". And $_ is implicitely printed at the end thanks to -p flag.
CJam, 4 bytes
q~Lt
Explanation
q~ e# Read and eval input (push the string and number to the stack).
Lt e# Set the nth element of the string to the empty string.
