Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- namespace EmojiDetector
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- long coolTreshHold = 1;
- int overallEmojies = 0;
- List<string> coolEmojies = new List<string>();
- Regex patternForNumber = new Regex(@"\d");
- MatchCollection matchForNumber = patternForNumber.Matches(input);
- foreach (Match number in matchForNumber)
- {
- int integer = int.Parse(number.Value);
- coolTreshHold *= integer;
- }
- Console.WriteLine($"Cool threshold: { coolTreshHold}");
- Regex patternForEmojis = new Regex(@"(?<tag>[:*]{2})(?<name>[A-Z][a-z]{2,})\k<tag>");
- MatchCollection matchesForEmoji = patternForEmojis.Matches(input);
- foreach (Match emoji in matchesForEmoji)
- {
- int sumForEmojies = 0;
- string currentEmoji = emoji.Value;
- overallEmojies++;
- for (int i = 0; i < currentEmoji.Length; i++)
- {
- char currentLetter = currentEmoji[i];
- if (Char.IsLetter(currentLetter))
- {
- sumForEmojies += (int)currentLetter;
- }
- }
- if (sumForEmojies>coolTreshHold)
- {
- coolEmojies.Add(currentEmoji);
- }
- }
- Console.WriteLine($"{overallEmojies} emojis found in the text. The cool ones are:");
- foreach (var item in coolEmojies)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement