Given a string
S and a list of indices
S by removing the element at each index of
S while using that result as the new value of
For example, given
S = 'codegolf' and
X = [1, 4, 4, 0, 2],
0 1 2 3 4 5 6 7 | c o d e g o l f | Remove 1 c d e g o l f | Remove 4 c d e g l f | Remove 4 c d e g f | Remove 0 d e g f | Remove 2 d e f
Your task is to perform this process, collect the values of
S after each operation, and display each on a newline in order. The final answer would be
S = 'codegolf' X = [1, 4, 4, 0, 2] Answer: codegolf cdegolf cdeglf cdegf degf def
- This is code-golf so make your code as short as possible.
- You may assume that the values in
Xare always valid indices for
S, and you may use either 0-based or 1-based indexing.
- The string will only contain
xmay by empty. If
Sis empty, it follows that
xmust also be empty.
- You may also take
Sas a list of characters instead of a string.
- You may either print the output or return a list of strings. Leading and trailing whitespace is acceptable. Any form of output is fine as long as it is easily readable.
S = 'abc', x =  'abc' 'bc' S = 'abc', x =  'abc' S = 'abc', x = [2, 0, 0] 'abc' 'ab' 'b' '' S = '', x =  '' S = 'codegolfing', x = [10, 9, 8, 3, 2, 1, 0] 'codegolfing' 'codegolfin' 'codegolfi' 'codegolf' 'codgolf' 'cogolf' 'cgolf' 'golf'