bounslay

Untitled

May 23rd, 2023
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. # Input
  2. # peshoishere
  3. # 3
  4. # eho
  5. # piere
  6. # telerik
  7. # Output
  8. # psishere
  9. # ssh
  10. # No such title found!
  11.  
  12.  
  13. title = input()
  14. n = int(input())
  15. words = [input() for _ in range(n)]
  16.  
  17.  
  18. for word in words:
  19.     temp_title = list(title)
  20.     indices = [0]
  21.  
  22.     for char in word:
  23.         if char in temp_title[indices[-1]:]:
  24.             current_index = temp_title[indices[-1]:].index(char)
  25.             temp_title[current_index + indices[-1]] = '_'
  26.             indices.append(current_index + indices[-1])
  27.             #print(current_index)
  28.    
  29.     if len(indices[1:]) == len(word):
  30.         title = []
  31.         #p_s__ishere
  32.         for char in temp_title:
  33.             if char != '_':
  34.                 title.append(char)
  35.        
  36.         print("".join(title))
  37.     else:
  38.         print("No such title found!")
Advertisement
Add Comment
Please, Sign In to add comment