String Processing

(Easy Problem No# 3)


A solution for this problem can be found here.

One day you wake up to find that you need to write a simple string processor. This string processor needs to read in a single line of text followed by a line of commands that will modify the string. Your program should output the line of processed text.

The commands are as follows:

  • 0   - move cursor to the start of the line
  • $   - move cursor to the position after the last character (end of line).
  • x   - delete the character at the cursor position if not at end of line.
  • s   - swap the character at the cursor with that to the right of it, as long as the cursor is not at or just before the end of the line.
  • i  x  - insert the character 'x' at the cursor posiion, and move the cursor along one space.
  • u   - make the character go into upper case if a letter, and move the cursor along one space.
  • +   - move the cursor right one space.
  • -   - move the cursor left one space.

  • The cursor can be at the first character, through to being at the position one after the last character. The input commands are in a single line following the input text line, not seperated by spaces. The input text line does not contain a carriage return. The cursor starts at the first character in the line for each text input line. The input is terminated by an input text line that contains only a single character, '#'.


    SAMPLE INPUT
    Hello, I am a frog.
    $-----xxxxipieirisioin
    Needle nardle noo.
    +++xizuu+++xxips
    #
    


    SAMPLE OUTPUT
    Hello, I am a person.
    NeezLE napel noo.
    


    ########################################################################## Competition Server comp@arcadia.cs.rmit.edu.au (via comp@cs.curtin.edu.au) Problems with server: contact Craig Dillon (cdillon@cs.curtin.edu.au) ##########################################################################