Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace P07TheVlogger
- {
- class Program
- {
- static void Main(string[] args)
- {
- var usernames = new HashSet<string>();
- var howManyFollowersUsersHave = new Dictionary<string, HashSet<string>>();
- var following = new Dictionary<string, HashSet<string>>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "Statistics")
- {
- break;
- }
- else
- {
- string[] commandsInfo = input
- .Split(" ", StringSplitOptions.RemoveEmptyEntries);
- string name = commandsInfo[0];
- if (commandsInfo.Length == 4)
- {
- string command = commandsInfo[1];
- string vloggerClub = commandsInfo[3];
- usernames.Add(name);
- if (usernames.Contains(name))
- {
- if (howManyFollowersUsersHave.ContainsKey(name) == false)
- {
- howManyFollowersUsersHave.Add(name, new HashSet<string>());
- }
- if (following.ContainsKey(name) == false)
- {
- following.Add(name, new HashSet<string>());
- }
- }
- }
- else if (commandsInfo.Length == 3)
- {
- string command = commandsInfo[1];
- string vlogger = commandsInfo[2];
- if (usernames.Contains(name)
- && usernames.Contains(vlogger)
- && name != vlogger)
- {
- if (howManyFollowersUsersHave.ContainsKey(vlogger) == false)
- {
- howManyFollowersUsersHave.Add(vlogger, new HashSet<string>());
- }
- howManyFollowersUsersHave[vlogger].Add(name);
- if (following.ContainsKey(name) == false)
- {
- following.Add(name, new HashSet<string>());
- }
- following[name].Add(vlogger);
- }
- }
- }
- }
- int count = 2;
- Console.WriteLine($"The V-Logger has a total of {usernames.Count} vloggers in its logs.");
- var topUser = howManyFollowersUsersHave
- .OrderByDescending(x => x.Value.Count)
- .ThenBy(g => following[g.Key].Count)
- .FirstOrDefault();
- Console.WriteLine($"1. {topUser.Key} : {topUser.Value.Count} followers, {following[topUser.Key].Count} following");
- foreach (var followers in topUser.Value.OrderBy(x=>x))
- {
- Console.WriteLine($"* {followers}");
- }
- foreach (var user in howManyFollowersUsersHave
- .Where(y=>y.Key != topUser.Key)
- .OrderByDescending(x => x.Value.Count)
- .ThenBy(y => following[y.Key].Count))
- {
- foreach (var item in following)
- {
- if (user.Key == item.Key)
- {
- Console.WriteLine($"{count}. {user.Key} : {user.Value.Count} followers, {item.Value.Count} following");
- count++;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement