Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _2.Password
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- var peshosFollowers = new Dictionary<string, int>();
- while (true)
- {
- if (input == "Log out")
- {
- break;
- }
- string[] commands = input
- .Split(": ");
- string command = commands[0];
- if (command == "New follower")
- {
- string username = commands[1];
- if (!peshosFollowers.ContainsKey(username))
- {
- peshosFollowers.Add(username, 0);
- }
- }
- else if (command == "Like")
- {
- string username = commands[1];
- int likesCount = int.Parse(commands[2]);
- if (!peshosFollowers.ContainsKey(username))
- {
- peshosFollowers.Add(username, likesCount);
- }
- else
- {
- peshosFollowers[username] += likesCount;
- }
- }
- else if (command == "Comment")
- {
- string username = commands[1];
- if (!peshosFollowers.ContainsKey(username))
- {
- peshosFollowers.Add(username, 1);
- }
- else
- {
- peshosFollowers[username] += 1;
- }
- }
- else if (command == "Blocked")
- {
- string username = commands[1];
- if (!peshosFollowers.ContainsKey(username))
- {
- Console.WriteLine($"{username} doesn't exist.");
- }
- else
- {
- peshosFollowers.Remove(username);
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine($"{peshosFollowers.Count} followers");
- foreach (var follower in peshosFollowers
- .OrderByDescending(x => x.Value)
- .ThenBy(x => x.Key)
- .ToDictionary(x => x.Key, x => x.Value))
- {
- Console.WriteLine($"{follower.Key}: {follower.Value}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment