Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Input
- # peshoishere
- # 3
- # eho
- # piere
- # telerik
- # Output
- # psishere
- # ssh
- # No such title found!
- title = input()
- n = int(input())
- words = [input() for _ in range(n)]
- for word in words:
- temp_title = list(title)
- indices = [0]
- for char in word:
- if char in temp_title[indices[-1]:]:
- current_index = temp_title[indices[-1]:].index(char)
- temp_title[current_index + indices[-1]] = '_'
- indices.append(current_index + indices[-1])
- #print(current_index)
- if len(indices[1:]) == len(word):
- title = []
- #p_s__ishere
- for char in temp_title:
- if char != '_':
- title.append(char)
- print("".join(title))
- else:
- print("No such title found!")
Advertisement
Add Comment
Please, Sign In to add comment