Nested Dictionary
Здравейте,
Темата е стара за C# от 2019, но на Java не успях да намеря решение. По-долу е условието. Ако може помощ за принтирането. Май и пълненето на маповете не е ок.
Nested Dictionary - Софтуерен университет (softuni.bg)
Опит за решение: Nested - Pastebin.com
You must read input lines until you receive the termination command “End”. On every input line (except the termination one) you will receive information in the following format:
“{person name} -> {liquid name}: {jars count}”
You must split the input and extract the needed information. Everything will be valid in the format described in the Input section.
You must collect all the different types of liquids for a person and sum the count of jars of every liquid for every person.
Input
The information will be in the following format:
- Person name – unique string which will not contain any of the characters that you have to split by (space, ‘-’, ‘>’, ‘:’)
- Liquid name – unique string which will not contain any of the characters that you have to split by (space, ‘-’, ‘>’, ‘:’)
- Jars count – integer number in range [0 … 100]
Output
You must print all liquids for a single person with their count of jars.
Order the people by their name (ascending) and the liquids by their count (ascending).
{Person Name} Liquids:
--- {Liquid Name}: {Count}
--- {Liquid Name}: {Count}
…
Examples:
Input |
Output |
Description |
Morgana -> Truelock: 2 Morgana -> Truelock: 89 Garrard -> Perigeaux: 96 Morgana -> Tott: 36 Arleta -> Sinnie: 15 Arleta -> Hutchin: 21 Emlyn -> Winslett: 92 Arleta -> Eam: 68 End |
Arleta Liquids: --- Sinnie: 15 --- Hutchin: 21 --- Eam: 68 Emlyn Liquids: --- Winslett: 92 Garrard Liquids: --- Perigeaux: 96 Morgana Liquids: --- Tott: 36 --- Truelock: 91 |
Arleta is first because of the ordering (by names). The liquids are ordered by count of jars (ascending). |