counter exercise

This commit is contained in:
anebz 2019-03-29 23:42:31 +01:00
parent 31b9f177d7
commit 766d118785
2 changed files with 27 additions and 1 deletions

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
.vscode/
*.exe
*.exe
*.inp
*.oac
*.out

View File

@ -0,0 +1,23 @@
# Python > Collections > collections.Counter()
# Use a counter to sum the amount of money earned by the shoe shop owner.
#
# https://www.hackerrank.com/challenges/collections-counter/problem
from collections import Counter
def calc_shoes():
input() # no. of shoes not used
shoes = Counter(input().split())
money = 0
for _ in range(int(input())):
shoe, price = input().split()
if shoe in shoes:
shoes[shoe] -= 1
if shoes[shoe] >= 0:
money += int(price)
return money
if __name__ == "__main__":
print(calc_shoes())