Programming Fundamentals Final Exam - 04 April 2020 Group 2 - 1. Password Reset

Получавам 16/100 в Judge и runtime errors, а във Visual Studio всичко се изпълнява правилно.

https://pastebin.com/5H7FdyRG

Write a password reset program that performs a series of commands upon a predefined string. First, you will receive a string and afterwards, until the command "Done" is given, you will be receiving strings with commands split by a single space. The commands will be the following:

  • TakeOdd
    •  Takes only the characters at odd indices and concatenates them together to
      obtain the new raw password and then prints it.
  • Cut {index} {length}
    • Gets the substring with the given length starting from the given index from the password and removes its first occurrence of it, then prints the password on the console.
    • The given index and length will always be valid.
  • Substitute {substring} {substitute}
    • If the raw password contains the given substring, replaces all of its
      occurrences with the substitute text given and prints the result.
    • If it doesn’t, prints "Nothing to replace!"

Input

  • You will be receiving strings until the "Done" command is given.

Output

  • After the "Done" command is received, print:
    • "Your password is: {password}"

Constraints

  • The indexes from the "Cut {index} {length}" command will always be valid.

Examples

Input

Output

Siiceercaroetavm!:?:ahsott.:i:nstupmomceqr

TakeOdd

Cut 15 3

Substitute :: -

Substitute | ^

Done

icecream::hot::summer

icecream::hot::mer

icecream-hot-mer

Nothing to replace!

Your password is: icecream-hot-mer

Comments

TakeOdd

Siiceercaroetavm!:?:ahsott.:i:nstupmomceqr -> icecream::hot::summer

We only take the chars at odd indices 1, 3, 5 etc.

Cut 15  3 -> icecream::hot::summer -> sum

icecream::hot::mer

We cut a substring starting at index 15 with length 3,

remove it from the raw password and print it.

Then, on a new line we print the resulting new raw password.

Substitute :: - -> icecream::hot::summer -> icream-hot-summer

We replace "::" with "-".

Substitute | ^ -> Nothing to replace!

"|" is not found anywhere in the raw password.

Finally, after receiving the "Done" command, we print the resulting password in the proper format.

Input

Output

up8rgoyg3r1atmlmpiunagt!-irs7!1fgulnnnqy

TakeOdd

Cut 18 2

Substitute ! ***

Substitute ? .!.

Done

programming!is!funny

programming!is!fun

programming***is***fun

Nothing to replace!

Your password is: programming***is***fun