Vim and Vigor
Statement
Most text editors just give you somewhere to type so that keys you press appear on the screen. Vim is different in that it provides <<modal>> editing: what a key does depends on which mode you're in.
In {{Insert}} mode, everything's pretty straightforward: typed keys simply appear in the buffer at the current cursor position. In {{Normal}} mode, however, keys will instead perform various actions rather than inserting text. There are hundreds of Vim commands, but for this problem we'll use just four, all of which simply enter Insert mode at different locations:
{{I}}: at the beginning of the line
{{A}}: at the end of the line ({{A}}ppend)
{{i}}: to the <<left>> of the character under the cursor
{{a}}: to the <<right>> of the character under the cursor
Consider the following line, highlighted to indicate that we're in Normal mode and our cursor is over the [[d]]:
abc[[d]]efg
This diagram shows where each of the commands places the cursor after entering Insert mode:
` a b c d e f g
I i a A`
Of course, we need a way to not get trapped in Insert mode: for this problem, {{^E}} will be used to represent the Escape key, which returns to Normal mode and places the cursor over the character to the left. abcd|efg -> abc[[d]]efg
‒‒‒‒‒‒‒‒‒‒
Given two lines of text, apply the second as a series of Vim keystrokes to the first and print the resulting line. <<Note>> that we always start in Normal mode with the cursor over the first character in the line.
Input description
<<Line 1:>> a string [[L]], the contents of a line in a Vim buffer
<<Line 2:>> a string [[V]], a series of characters to be executed as Vim keystrokes
Output description
<<Line 1:>> the result of executing [[V]] on [[L]]
Constraints
Game modes
Test cases
A Test
Input
exam
Aple
Output
example
A (validator) Validator
Input
valid
Aator
Output
validator
I Test
Input
ert
Iins
Output
insert
I (validator) Validator
Input
ator
Ivalid
Output
validator
A I Escape Test
Input
inG
Aame^EICod
Output
CodinGame
A I Escape (validator) Validator
Input
ida
Ator^EIval
Output
validator
a Test
Input
far
aoob
Output
foobar
a (validator) Validator
Input
vator
aalid
Output
validator
Putting it all together Test
Input
s is a s
Aentenc.^Eie^EITh^Eai
Output
This is a sentence.
Putting it all together (validator) Validator
Input
s is a v
Aalidato.^Eir^EITh^Eai
Output
This is a validator.
Solution language
Solution
Stub generator input