viligen

treasure_finder

Nov 12th, 2021
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. key_list = list(map(int, input().split()))
  2.  
  3. while True:
  4.     text = input()
  5.     if text == "find":
  6.         break
  7.     new_text = ''
  8.     for index in range(len(text)):
  9.         index_key = index
  10.         if index_key >= len(key_list):
  11.             index_key %= len(key_list)
  12.         letter = chr(ord(text[index])-key_list[index_key])
  13.         new_text += letter
  14.  
  15.     start_type_index = new_text.index("&")
  16.     end_type_index = start_type_index + 1 + new_text[start_type_index+1:].index("&")
  17.     type_treasure = new_text[start_type_index+1:end_type_index]
  18.  
  19.     start_coordinate_index = new_text.index("<")
  20.     end_coordinate_index = new_text.index(">")
  21.     coordinates = new_text[start_coordinate_index + 1:end_coordinate_index]
  22.  
  23.     print(f"Found {type_treasure} at {coordinates}")
  24.  
Advertisement
Add Comment
Please, Sign In to add comment