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