Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools as it
- keys = [int(x) for x in input().split()]
- def extract_treasure(a: str, x: str):
- _result = ''
- idx = a.index(x) + 1
- while True:
- if a[idx] == '&':
- break
- _result += a[idx]
- idx += 1
- return _result
- def extract_location(a: str, x: str):
- result_ = ''
- idx = a.index(x) + 1
- while a[idx] != '>':
- result_ += a[idx]
- idx += 1
- return result_
- while True:
- text = input()
- if text == 'find':
- break
- new_text = ''
- for x, y in zip(text, it.cycle(keys)):
- new_chr = chr(ord(x) - y)
- new_text += new_chr
- i= 0
- treasure = ''
- location = ''
- while i < len(new_text):
- if new_text[i] == '&':
- treasure = extract_treasure(new_text, new_text[i])
- i += len(treasure) + 1
- elif new_text[i] == '<':
- location = extract_location(new_text, new_text[i])
- i += len(location)
- i += 1
- print(f'Found {treasure} at {location}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement