Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 02. Judge Dictionaries - More Exercises 100/100
- # https://judge.softuni.org/Contests/Practice/Index/1738#1
- def calculate_individual_points_func():
- max_points = {}
- for current_name, current_points in my_dict.items():
- for key, value in current_points.items():
- if key not in max_points:
- max_points[key] = value
- else:
- max_points[key] += value
- counter = 0
- print('Individual standings:')
- for current_name, score in sorted(max_points.items(), key=lambda kvp: (-kvp[1], kvp[0])):
- counter += 1
- print(f"{counter}. {current_name} -> {score}")
- data = input()
- my_dict = {}
- while not data == 'no more time':
- details = data.split(" -> ")
- name = details[0]
- contest = details[1]
- points = int(details[2])
- if contest not in my_dict.keys():
- my_dict[contest] = {name: points}
- elif contest in my_dict.keys():
- if name in my_dict[contest]:
- old_points = my_dict[contest][name]
- if points > old_points:
- my_dict[contest].update({name: points})
- else:
- my_dict[contest].update({name: points})
- data = input()
- for k, v in my_dict.items():
- print(f"{k}: {len(v.keys())} participants")
- student_counter = 0
- for name, point in sorted(v.items(), key=lambda kvp: (-kvp[1], kvp[0])):
- student_counter += 1
- print(f"{student_counter}. {name} <::> {point}")
- calculate_individual_points_func()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement