Advertisement
horozov86

The Imitaion Game

Mar 22nd, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. message = input()
  2.  
  3. while True:
  4.     line = input()
  5.     if line == "Decode":
  6.         break
  7.    
  8.     line_split = line.split("|")
  9.     command = line_split[0]
  10.    
  11.     if command == "Move":
  12.         number_of_letters = int(line_split[1])
  13.         part_replace = message[:number_of_letters]
  14.         message = message.replace(part_replace, "") + part_replace
  15.        
  16.     elif command == "Insert":
  17.         given_index = int(line_split[1])
  18.         given_value = line_split[2]
  19.         message = message[:given_index] + given_value + message[given_index:]
  20.    
  21.     else:
  22.         substring = line_split[1]
  23.         replacement = line_split[2]
  24.         message = message.replace(substring, replacement)
  25.        
  26. print(f"The decrypted message is: {message}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement