Advertisement
go6odn28

12_softuni_exam_result.

Apr 14th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. all_results = {}
  2. best_results = {}
  3.  
  4. command = input()
  5.  
  6. while command != "exam finished":
  7.     command = command.split("-")
  8.     username = command[0]
  9.     if command[1] == "banned":
  10.         if username in best_results.keys():
  11.             del best_results[username]
  12.     else:
  13.         language = command[1]
  14.         points = int(command[2])
  15.         if language not in all_results:
  16.             all_results[language] = 0
  17.         all_results[language] += 1
  18.         if username not in best_results.keys():
  19.             best_results[username] = {'language': language, 'points': points}
  20.         else:
  21.             if points > best_results[username]['points']:
  22.                 best_results[username] = {'language': language, 'points': points}
  23.  
  24.     command = input()
  25.  
  26. print("Results:")
  27. for key, value in best_results.items():
  28.     print(f"{key} | {value['points']}")
  29.  
  30. print("Submissions:")
  31. for lang, num in all_results.items():
  32.     print(f"{lang} - {num}")
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement