[Programming Fundamentals] Extended - Strings and Text Processing - Exercises - 05. Points Counter
Здравейте колеги,
Решението ми дава 83/100. Мисля, че проблема ми идва от това, че не съм записал всеки играч отделно, тъй като ако се въведе играч със същото име трябва да се извади резултата му от общата стойност и да се добави новият, което съм го направил, но действа само ако играча, който съм въвел е с най-високия резултат. Пробвах да записвам всеки играч отделно, но задачата се заплете и стана 50/100. В момента съм я върнал на 83/100.
-решение https://pastebin.com/4DZsjfNF
5. Points Counter
Write a program, which receives data about a team, player and points.
Input
You can have two types of input:
- {TEAM}|{Player}|{points}
- {Player}|{TEAM}|{points}
The team name will always consist of uppercase Latin letters and the player name will always start with uppercase Latin letter and all other letters will be lowercase.
The team and player names might be polluted with some prohibited symbols (‘@’, ‘%’, ‘$’ and ‘*’). You have to delete every occurrence of these symbols in every team and player name.
Then, calculate every team’s total score. Every team’s total score equals to the total sum of the points made by every player in the team.
Output
When you receive the command “Result”, print all teams, ordered in descending order by the points they made and the player with most points in the team in the following format:
{teamName} => {totalSumOfPoints} Most points scored by: {nameOfThePlayer} |
In case of repeating player names for one team, save the value, which is received last.
Constraints
- The team names will be at least 2 characters long
- The points for each player will be in the interval [1…100]
Examples
Input |
Output |
LA|Bryant|70 L%@A|Odom|67 James|%CAVA@@LIE$$$RS|54 C@art%er|GR%%IZZ%%LIE@S@@@|49 Anthony|KNICKS|11 UTAH|Jo%%%%hn$$so@@n|24 S@@PU*R*S$|Ga***so**l|32 Jone@@@@s|KNICKS|5 Result |
LA => 137 Most points scored by Bryant CAVALIERS => 54 Most points scored by James GRIZZLIES => 49 Most points scored by Carter SPURS => 32 Most points scored by Gasol UTAH => 24 Most points scored by Johnson KNICKS => 16 Most points scored by Anthony |
SO@@@FTU%*NI|P*&@esho|30 SO$$FT*UNI|Gos%@ho|42 PAARTHURNAX|Maria|35 S*OFT$$$UNI|Iv****@an|3 L@u*b%o@|HE***RO@@ES|11 Result |
SOFTUNI => 75 Most points scored by Gosho PAARTHURNAX => 35 Most points scored by Maria HEROES => 11 Most points scored by Lubo |