Advertisement
Stan0033

Untitled

Aug 9th, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Text;
  6. namespace apps
  7. {
  8. class Program
  9. {
  10. static string Get() { return Console.ReadLine(); }
  11. static int GetInt() { return int.Parse(Console.ReadLine()); }
  12. static void Main()
  13. {
  14.  
  15. //emoji detector
  16. string text = Get();
  17. string pattern = @"([:*]{2})(?<word>[A-Z]{1}[a-z]{3,})\1";
  18. MatchCollection matches = Regex.Matches(text, pattern);
  19. List<string> emojis = new List<string>();
  20. int coolness_threshold = 0;
  21. foreach (Match m in matches)
  22. {
  23. string match = m.ToString();
  24. match.Trim();
  25. emojis.Add(match);
  26. string word = m.Groups["word"].ToString(); //match.All(x => char.IsLetter(x)).ToString() ;
  27. int total = 0;
  28. foreach (char c in word)
  29. {
  30. int value = (int)c;
  31. total += value;
  32.  
  33. }
  34.  
  35. coolness_threshold += total;
  36.  
  37. }
  38.  
  39. Console.WriteLine($"Cool threshold: {coolness_threshold}");
  40. Console.WriteLine($"{emojis.Count} emojis found in the text. The cool ones are:");
  41. Console.WriteLine(string.Join("\n", emojis));
  42. }
  43. }
  44. }// END MAIN
  45.  
  46.  
  47.  
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement