Advertisement
Threed90

Emojis

Aug 13th, 2021
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Numerics;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Exr
  10. {
  11.     public class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             var input = Console.ReadLine();
  16.  
  17.             MatchCollection digitMatch = Regex.Matches(input, @"\d");
  18.  
  19.             int coolness = 1;
  20.  
  21.             foreach (var digit in digitMatch.Select(x => x.Value))
  22.             {
  23.                 coolness *= int.Parse(digit);
  24.             }
  25.  
  26.             Console.WriteLine($"Cool threshold: {coolness}");
  27.  
  28.             MatchCollection matches = Regex.Matches(input, @"(::|\*\*)(?<word>[A-Z][a-z]{2,})\1");
  29.  
  30.             if(matches.Count == 0)
  31.             {
  32.                 return;
  33.             }
  34.  
  35.             Console.WriteLine($"{matches.Count} emojis found in the text. The cool ones are:");
  36.  
  37.             foreach (Match match in matches)
  38.             {
  39.                 int currentCoolness = match.Groups["word"].Value.Sum(c => c);
  40.  
  41.                 if(currentCoolness >= coolness)
  42.                 {
  43.                     Console.WriteLine(match.Value);
  44.                 }
  45.             }
  46.         }
  47.  
  48.     }
  49.  
  50.  
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement