Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Boyan.Georgiev avatar Boyan.Georgiev 1 Точки

90/100 Followers - 9 August 2019

Здравейте,

понеже на няколко от изпитните задачи с речниците имам 90/100 точки, явно допускам една и съща грешка.

Ако може да кажете къде е грешката в този код :https://pastebin.com/fbvVasr5

 

Условието на задачата: 

Followers

Now that Pesho has successfully created an account, he wants to connect with other users and gain as many followers, likes and comments as possible.

Create a program that keeps information about Pesho's followers, likes and comments. Keep a record of the followers, each with the likes and comments Pesho has received from them.

You will be receiving lines with commands until you receive the "Log out" command.  There are four possible commands:

  • "New follower: {username}":
    • Add the username, to your records (with 0 likes and 0 comments). If person with the given username already exists ignore the line.
  • "Like: {username}: {count}":
    • If the username doesn't exist, add it to your records with the given count of likes.
    • If the username exist, increase the count of likes with the given count.
  • "Comment: {username}":
    • If the username doesn't exist, add it to your records with 1 comment.
    • If the username exists, increase the count of commens with 1.
  • "Blocked: {username}":
    • Delete all records of the given username. If it doesn’t exist, print:

 "{Username} doesn't exist."

 

In the end, you have to print the count of followers, each follower with his/her likes and comments (the sum of likes and comments) sorted in descending order by the likes and then by their username in ascending order in the following format: 

{count} followers

{username}: {likes+comments}

{username}: {likes+comments}

...

Input

  • You will be receiving lines until you receive the "Log out" command.
  • The input will always be valid.

Output

  • Print the users with their likes in the format described above.

Examples

Input

Output

New follower: gosho

Like: gosho: 5

Comment: gosho

New follower: gosho

New follower: tosho

Comment: gosho

Comment: tosho

Comment: pesho

Log out

3 followers

gosho: 7

pesho: 1

tosho: 1

Input

Output

Like: A: 3

Comment: A

New follower: B

Blocked: A

Comment: B

Like: C: 5

Like: D: 5

Log out

3 followers

C: 5

D: 5

B: 1

 

Тагове:
0
Module: C# Advanced
VasilKos avatar VasilKos 17 Точки

Може ли малко помощ за принтирането накрая.

Followers - Pastebin.com

Първият вход излиза, проблемът е при втория.

followers.entrySet().stream().sorted((e1, e2) -> Integer.compare(e2.getValue().size(), e1.getValue().size()))
        .forEach(entry -> {
            System.out.printf("%s: %d%n", entry.getKey(), entry.getValue().get(0)+entry.getValue().get(1));
        });
0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.