Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 03. Treasure Finder Text Processing - More Exercises 100/100
- # https://judge.softuni.org/Contests/Practice/Index/1741#0
- def find_treasure(some_str: str):
- some_str = some_str.split('&')
- treasure_found = some_str[1]
- return treasure_found
- def find_location(some_str):
- start_index = some_str.index('<')
- end_index = some_str.index('>')
- location_found = some_str[start_index+1:end_index]
- return location_found
- keys = list(map(int, input().split(" ")))
- command = input()
- while not command == 'find':
- new_string = ""
- string = command
- index_counter = 0
- key_counter = 0
- len_of_string = len(string)
- while True:
- len_of_string -= 1
- if len_of_string < 0:
- break
- new_string += chr((ord(string[index_counter]) - keys[key_counter]))
- index_counter += 1
- key_counter += 1
- if index_counter % len(keys) == 0:
- index_counter = len(new_string)
- key_counter = 0
- treasure = find_treasure(new_string)
- location = find_location(new_string)
- print(f'Found {treasure} at {location}')
- command = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement