Advertisement
silvana1303

emoji detector

Aug 6th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Runtime.InteropServices;
  6. using System.Data;
  7. using System.IO;
  8.  
  9. namespace _02._Boss_Rush
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Regex word = new Regex(@"(::|\*\*)(?<word>[A-Z][a-z]{2,})\1");
  16.             Regex digit = new Regex(@"[0-9]");
  17.  
  18.             List<string> coolest = new List<string>();
  19.  
  20.             string input = Console.ReadLine();
  21.  
  22.             int cool = 1;
  23.  
  24.             MatchCollection digits = digit.Matches(input);
  25.  
  26.             foreach (Match item in digits)
  27.             {
  28.                 if (item.Success)
  29.                 {
  30.                     int d = int.Parse(item.Value);
  31.                     cool *= d;
  32.                 }
  33.             }
  34.  
  35.             MatchCollection words = word.Matches(input);
  36.  
  37.             foreach (Match item in words)
  38.             {
  39.                 if (item.Success)
  40.                 {
  41.                     int count = 0;
  42.  
  43.                     string threshold = item.Groups["word"].Value;
  44.  
  45.                     string add = item.Value;
  46.  
  47.                     char[] wealth = threshold.ToCharArray();
  48.  
  49.                     foreach (char stuff in wealth)
  50.                     {
  51.                         count += stuff;
  52.                     }
  53.  
  54.                     if (count >= cool)
  55.                     {
  56.                         coolest.Add(add);
  57.                     }
  58.                 }
  59.             }
  60.  
  61.             Console.WriteLine($"Cool threshold: {cool}");
  62.             Console.WriteLine($"{words.Count} emojis found in the text. The cool ones are:");
  63.             if (coolest.Count > 0)
  64.             {
  65.                 Console.WriteLine(string.Join(Environment.NewLine, coolest));
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement