viligen

imitation_game

Oct 22nd, 2021
797
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. text = list(input())
  2.  
  3. while True:
  4.     command = input()
  5.     if "Decode" in command:
  6.         break
  7.     instructions = command.split("|")
  8.     if "Move" in instructions:
  9.         n = int(instructions[1])
  10.         text1 = text[:n]
  11.         text2 = text[n:]
  12.         text = text2 + text1
  13.     elif "Insert" in instructions:
  14.         index = int(instructions[1])
  15.         value = instructions[2]
  16.         text.insert(index, value)
  17.         text = list("".join(text))
  18.     elif "ChangeAll" in instructions:
  19.         substring = instructions[1]
  20.         replacement = instructions[2]
  21.         text = [replacement if s == substring else s for s in text]
  22.  
  23. print(f"The decrypted message is: {''.join(text)}")
  24.  
RAW Paste Data