Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4. using System.Collections.Generic;
  5. namespace EmojiDetector
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.            
  12.             string input = Console.ReadLine();
  13.             long coolTreshHold = 1;
  14.            
  15.  
  16.  
  17.             int overallEmojies = 0;
  18.             List<string> coolEmojies = new List<string>();
  19.            
  20.            
  21.             Regex patternForNumber = new Regex(@"\d");
  22.               MatchCollection matchForNumber = patternForNumber.Matches(input);
  23.                 foreach (Match number in matchForNumber)
  24.                 {
  25.                     int integer = int.Parse(number.Value);
  26.                 coolTreshHold *= integer;                
  27.  
  28.                 }
  29.             Console.WriteLine($"Cool threshold: { coolTreshHold}");
  30.             Regex patternForEmojis = new Regex(@"(?<tag>[:*]{2})(?<name>[A-Z][a-z]{2,})\k<tag>");
  31.             MatchCollection matchesForEmoji = patternForEmojis.Matches(input);
  32.             foreach  (Match emoji in matchesForEmoji)
  33.             {
  34.                 int sumForEmojies = 0;
  35.                 string currentEmoji = emoji.Value;
  36.                 overallEmojies++;
  37.                
  38.                 for (int i = 0; i < currentEmoji.Length; i++)
  39.                 {
  40.                     char currentLetter = currentEmoji[i];
  41.                     if (Char.IsLetter(currentLetter))
  42.                     {
  43.                         sumForEmojies += (int)currentLetter;
  44.                     }
  45.                    
  46.                 }
  47.                 if (sumForEmojies>coolTreshHold)
  48.                 {
  49.                     coolEmojies.Add(currentEmoji);
  50.                 }
  51.             }
  52.             Console.WriteLine($"{overallEmojies} emojis found in the text. The cool ones are:");
  53.             foreach (var item in coolEmojies)
  54.             {
  55.                 Console.WriteLine(item);
  56.             }
  57.            
  58.          
  59.            
  60.  
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement