Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- score = 0
- total_score = 0
- main_word = list(input())
- main_letters = sorted(list(set(main_word)))
- main_quantity = list()
- for letter in main_letters:
- main_quantity.append(main_word.count(letter))
- N = int(input())
- for _ in range(N):
- word = list(input())
- letters = main_letters.copy()
- quantity = main_quantity.copy()
- for index, letter in enumerate(word):
- if letter not in letters or quantity[letters.index(letter)] < 0:
- score = 0
- break
- else:
- score += 1
- quantity[letters.index(letter)] -= 1
- total_score += score
- score = 0
- print(total_score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement