Advertisement
Jaood_xD

Untitled

Dec 2nd, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace ClassTestSolution
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string txt = @"# Sleep tired admins mouse sleeping …
  12. # Flash drives and keyboards wait guys …
  13. # Windows, too, goes to bed,
  14. # That night we had a dream
  15. # ICQ shut up… Ba-you-buy.
  16. # All normal contacts asleep long ago …
  17. # Virus climbs into folders, anyway …
  18. # Soon he falls too, well, we’ll help him —
  19. # Databases are updated, the ba-you-buy …";
  20.  
  21.             Regex.Replace(txt, "[—,….#\r\n]", match => "")
  22.                 .Split(' ')
  23.                 .GroupBy(x => x)
  24.                 .Where(x => x.Key != "")
  25.                 .OrderByDescending(x => x.Count())
  26.                 .ToList()
  27.                 .ForEach(x => Console.Write($@"(""{x.Key}"",{x.Count()}),"));
  28.         }
  29.  
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement