Dictionaries - More Exercises - 02. Judge - Python

Здравейте колеги,

някой да вижда къде е грешката, че аз вече не я виждам.

Моето решение - 83/100 -> https://pastebin.com/jX77ufV4

Предполагам че е тук, но...:

sorted_names = dict(sorted(users.items(), key=lambda x: (-sum(x[1].values()), x[0])))

Условие:

2.Judge

You know the jude system, right?! Your job is to create a program similar to the Judge system.

You will receive several input lines in one of the following formats:

{username} -> {contest} -> {points}

The constestName and username are strings, the given points will be an integer number. You need to keep track of every contest and individual statistics of every user. You should check if such contest already exists, and if not, add it, otherwise check if the current user Is participating in the contest, if he is participating take the higher score, otherwise just add it.

Also you need to keep individual statistics for each user - the total points of all constests.

You should end your program when you receive the command "no more time". At that point you should print each contest in order of input, for each contest print the participants ordered by points in desecending order, than ordered by name in ascending order.  After that, you should print individual statistics for every participant ordered by total points in desecnding order, and then by alphabetical order.

Input / Constraints

  • The input comes in the form of commands in one of the formats specified above.
  • Username and contest name always will be one word.
  • Points will be an integer will be an integer in range [0, 1000].
  • There will be no invalid input lines.
  • If all sorting criteria fail, the order should be by order of input.
  • The input ends when you receive the command "no more time".

Output

  • The output format for the contests is:

{constestName}: {participants.Count} participants

{position}. {username} <::> {points}

  • After you print all contests, print the individual statistics for every participant.
  • The output format is:

Individual standings:

{position}. {username} -> {totalPoints}

Examples

Input

Output

Pesho -> Algo -> 400

Gosho -> Algo -> 300

Stamat -> Algo -> 200

Pesho -> DS -> 150

Mimi -> DS -> 600

no more time

Algo: 3 participants

1. Pesho <::> 400

2. Gosho <::> 300

3. Stamat <::> 200

DS: 2 participants

1. Mimi <::> 600

2. Pesho <::> 150

Individual standings:

1. Mimi -> 600

2. Pesho -> 550

3. Gosho -> 300

4. Stamat -> 200

 

Pesho -> OOP -> 350

Gosho -> OOP -> 250

Stamat -> Advanced -> 600

Gosho -> OOP -> 300

Prakash -> OOP -> 300

Prakash -> Advanced -> 250

Ani -> JSCore -> 400

no more time

OOP: 3 participants

1. Pesho <::> 350

2. Gosho <::> 300

3. Prakash <::> 300

Advanced: 2 participants

1. Stamat <::> 600

2. Prakash <::> 250

JSCore: 1 participants

1. Ani <::> 400

Individual standings:

1. Stamat -> 600

2. Prakash -> 550

3. Ani -> 400

4. Pesho -> 350

5. Gosho -> 300