Advertisement
jootiee

Untitled

Dec 4th, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. score = 0
  2. total_score = 0
  3.  
  4. main_word = list(input())
  5. main_letters = sorted(list(set(main_word)))
  6. main_quantity = list()
  7. for letter in main_letters:
  8.     main_quantity.append(main_word.count(letter))
  9.  
  10. N = int(input())
  11.  
  12. for _ in range(N):
  13.     word = list(input())
  14.     letters = main_letters.copy()
  15.     quantity = main_quantity.copy()
  16.     for index, letter in enumerate(word):
  17.         if letter not in letters or quantity[letters.index(letter)] < 0:
  18.             score = 0
  19.             break
  20.         else:
  21.             score += 1
  22.             quantity[letters.index(letter)] -= 1
  23.     total_score += score
  24.     score = 0
  25.  
  26. print(total_score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement