Advertisement
Spocoman

01. The Imitation Game

Nov 13th, 2023
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. message = input()
  2.  
  3. while True:
  4.     command = input()
  5.     if command == "Decode":
  6.         break
  7.     tokens = command.split('|')
  8.     command = tokens[0]
  9.     if command == "Move":
  10.         index = int(tokens[1])
  11.         message = message[index:] + message[: index]
  12.     elif command == "Insert":
  13.         index = int(tokens[1])
  14.         value = tokens[2]
  15.         message = message[:index] + value + message[index:]
  16.     elif command == "ChangeAll":
  17.         old = tokens[1]
  18.         new = tokens[2]
  19.         message = message.replace(old, new)
  20.  
  21. print(f"The decrypted message is: {message}")
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement