Python Fundamental Finale Exam-01.Problem Galactic Code Decryption

Здравейте! Във въпросният код получавам 66/100 точки. Защо?

Solution #41058677 by usmiwka80 for problem 01. Galactic Code Decryption

Problem 1 – Galactic Code Decryption

Welcome codebreaker. You have been recruited by the Galactic Federation to assist in deciphering transmissions intercepted from a mysterios alien civilization. These coded messages are crucial for understanding their technology and intentions. Your mission is to modify these transmissions using a set of decryption commands until the command "Finalize" is given.

 

You are provided with a coded message in the form of a string. Until receiving the command "Finalize" you must process this string using various commands to manipulate and decode the message. Each command will alter the message in a specified manner:

  • "Encrypt"
    • Reverse the order of the characters in the message.
    • Print the message.
  • "Decrypt"
    • Swap the case of all characters in the message (uppercase to lowercase, lowercase to uppercase).
    • Print the message.
  • "Substitute {old_char} {new_char}"
    • Replace all occurrences of the specified character {old_char} (case-sensitive!) with the character {new_char}.
    • Print the message.
    • If {old_char} is not found, print: "Character not found.".
  • "Scramble {index} {char}"
    • Replace the character at the specified index with {char}.
    • Print the message.
    • If the index is out of range, print: "Index out of bounds.".
  • "Remove {substring}"
    • Delete all instances of the specified substring from the message (case-sensitive!) .
    • Print the message.

If a command that does not match any of the above is received, print "Invalid command detected!".

Input / Constraints

  • The first line will contain the initial coded message as a string.
  • Subsequent line will contain commands until the "Finalize" command is encountered.
  • All commands are case-sensitive.

Output

  • Print the output of the commands in the format described above.

Examples

Input

Output

helloWorld

Encrypt

Decrypt

Substitute L z

Remove O

Scramble 0 H

Invalid command detected!

Finalize

dlroWolleh

DLROwOLLEH

DzROwOzzEH

DzRwzzEH

HzRwzzEH

Invalid command detected!

GalacticMission

Decrypt

Scramble 5 Z

Remove S

Substitute G X

Encrypt

Finalize

gALACTICmISSION

gALACZICmISSION

gALACZICmIION

Character not found.

NOIImCIZCALAg

Federation1

Encrypt

Decrypt

Remove 1

Substitute E e

Scramble 2 X

Encrypt

Finalize

1noitaredeF

1NOITAREDEf

NOITAREDEf

NOITAReDef

NOXTAReDef

feDeRATXON