Advertisement
GeorgiLukanov87

12. SoftUni Exam Results - Dictionaries - Exercise

Jul 5th, 2022
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. # 12. SoftUni Exam Results - 100/100
  2. # Dictionaries - Exercise
  3. # https://judge.softuni.org/Contests/Compete/Index/1737#11
  4.  
  5.  
  6. command = input()
  7. data = {}
  8. all_languages = []
  9. count_languages = []
  10.  
  11. while not command == 'exam finished':
  12.     command = command.split("-")
  13.     if command[1] == "banned":
  14.         name = command[0]
  15.         del data[name]
  16.         command = input()
  17.         continue
  18.     elif not command[1] == 'banned':
  19.         name = command[0]
  20.         language = command[1]
  21.         points = int(command[2])
  22.     if name not in data:
  23.         data[name] = points
  24.     else:
  25.         if points > data[name]:
  26.             data[name] = points
  27.     all_languages += [language]
  28.    
  29.     if language not in count_languages:
  30.         count_languages.append(language)
  31.  
  32.     command = input()
  33.  
  34. print('Results:')
  35. for name, points in data.items():
  36.     print(f'{name} | {points}')
  37.  
  38. print('Submissions:')
  39. for subm in range(len(count_languages)):
  40.     result = count_languages[subm]
  41.     print(f"{count_languages[subm]} - {all_languages.count(result)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement