Advertisement
Nenogzar

12. *SoftUni Exam Results

Mar 4th, 2024
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.09 KB | None | 0 0
  1. university = {}
  2. language_counts = {}
  3. collect = input()
  4.  
  5. while collect != "exam finished":
  6.     if "banned" in collect.split("-"):
  7.         username = collect.split("-")[0]
  8.         del university[username]
  9.     else:
  10.         username, language, points = collect.split("-")
  11.         language_counts[language] = language_counts.get(language, 0) + 1
  12.         points = int(points)
  13.         if username not in university:
  14.             university[username] = {language: points}
  15.         else:
  16.             if language not in university[username]:
  17.                 university[username][language] = points
  18.             else:
  19.                 if points > university[username][language]:
  20.                     university[username][language] = points
  21.  
  22.     collect = input()
  23. # print(university)
  24. # print(language_counts)
  25. print("Results:")
  26. for user, scores in university.items():
  27.     for language, points in scores.items():
  28.         print(f"{user} | {points}")
  29.  
  30. print("Submissions:")
  31. for language, count in language_counts.items():
  32.     print(f"{language} - {count}")
  33.  
  34. """ """
  35.  
  36. university = {}
  37.  
  38. collect = input()
  39. while collect != "exam finished":
  40.     if "banned" in collect.split("-"):
  41.         username = collect.split("-")[0]
  42.         del university[language]["users"][username]
  43.     else:
  44.         username, language, points = collect.split("-")
  45.         points = int(points)
  46.         if language not in university:
  47.             university[language] = {"count": 1, "users": {username: points}}
  48.         else:
  49.             university[language]["count"] += 1
  50.             if username not in university[language]["users"]:
  51.                 university[language]["users"][username] = points
  52.             else:
  53.                 if points > university[language]["users"][username]:
  54.                     university[language]["users"][username] = points
  55.  
  56.     collect = input()
  57.  
  58. print("Results:")
  59. for language, data in university.items():
  60.     for user, points in data["users"].items():
  61.         print(f"{user} | {points}")
  62.  
  63. print("Submissions:")
  64. for language, data in university.items():
  65.     print(f"{language} - {data['count']}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement