Some people like to have a particular custom signature following their emails or posts on online message boards. These signatures usually contain the handle by which they are known, but then are decorated by various punctuation marks to make them look more interesting. You, as administrator of a popular message board, would like to allow such decorations in people's signatures while enforcing a rule that the signature they use contains their name. In order to do this, you allow people to set up a series of rules to apply to their handles to automatically generate their signatures.
You will be given a user's handle as a String, which will be made up of upper- and lower-case letters, numbers or underscores ('_'). You will also be given two String[]s representing a series of formatting commands. Each element in commands is "prepend", "append" or "surround". Each element of decorations is a series of punctuation characters (out of ,./;'<>?:"\|[]{}-=_+!@#$%^&*()~` ) to use. The ith element of commands corresponds to the ith element of decorations.
Each instruction should be executed as follows:
- For a "prepend" command, put the decoration at the beginning of the name.
- For an "append" command, put the decoration at the end of the name.
- For a "surround" command, put the decoration at the beginning of the name and backwards at the end of the name.
The instructions should be executed in the order in which they appear, so if name is "Bob", commands is {"surround", "append", "prepend"}, and decorations is {"-=", "(", ")"} name would progressively go from "Bob" to "-=Bob=-" to "-=Bob=-(" to ")-=Bob=-(". |