Advertisement
silvana1303

followers

Aug 7th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _02._Boss_Rush
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string[] command = Console.ReadLine().Split(": ");
  13.  
  14.             Dictionary<string, int> likes = new Dictionary<string, int>();
  15.             Dictionary<string, int> comment = new Dictionary<string, int>();
  16.  
  17.             while (command[0] != "Log out")
  18.             {
  19.                 if (command[0] == "New follower")
  20.                 {
  21.                     if (!likes.ContainsKey(command[1]))
  22.                     {
  23.                         likes[command[1]] = 0;
  24.                         comment[command[1]] = 0;
  25.                     }
  26.                 }
  27.                 if (command[0] == "Like")
  28.                 {
  29.                     int count = int.Parse(command[2]);
  30.                     if (likes.ContainsKey(command[1]))
  31.                     {
  32.                         likes[command[1]] += count;
  33.                     }
  34.                     else
  35.                     {
  36.                         likes[command[1]] = count;
  37.                         comment[command[1]] = 0;
  38.                     }
  39.                 }
  40.                 if (command[0] == "Comment")
  41.                 {
  42.                    
  43.                     if (comment.ContainsKey(command[1]))
  44.                     {
  45.                         comment[command[1]] ++;
  46.                     }
  47.                     else
  48.                     {
  49.                         likes[command[1]] = 0;
  50.                         comment[command[1]] = 1;
  51.                     }
  52.                 }
  53.                 if (command[0] == "Blocked")
  54.                 {
  55.                     if (likes.ContainsKey(command[1]))
  56.                     {
  57.                         likes.Remove(command[1]);
  58.                         comment.Remove(command[1]);
  59.                     }
  60.                     else
  61.                     {
  62.                         Console.WriteLine($"{command[1]} doesn't exist.");
  63.                     }
  64.                 }
  65.  
  66.                 command = Console.ReadLine().Split(": ");
  67.             }
  68.  
  69.             Console.WriteLine($"{likes.Count} followers");
  70.             foreach (var item in likes.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
  71.             {
  72.                 Console.WriteLine($"{item.Key}: {item.Value + comment[item.Key]}");
  73.             }
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement