Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Numerics;
- using System.Text.RegularExpressions;
- namespace EmojiDetector
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- var listCoolEmojies = new List<string>();
- Regex regexForThreshold = new Regex(@"[0-9]");
- MatchCollection matchesForThreshold = regexForThreshold.Matches(input);
- BigInteger threshold = 1;
- foreach (Match match in matchesForThreshold)
- {
- string matchString= (match.Value);
- int number = int.Parse(matchString);
- threshold = threshold * number;
- }
- Regex regexForEmojies = new Regex(@"(::|\*\*)(?<emoji>[A-Z][a-z]{2,})\1");
- MatchCollection matchesValidEmojies = regexForEmojies.Matches(input);
- foreach (Match match in matchesValidEmojies )
- {
- string validEmoji = match.Value;
- string validEmojiOnlyLetter = match.Groups["emoji"].Value;
- int sumASCII = 0;
- for (int i = 0; i < validEmojiOnlyLetter.Length; i++)
- {
- sumASCII += validEmojiOnlyLetter[i];
- }
- if(sumASCII > threshold)
- {
- listCoolEmojies.Add(validEmoji);
- }
- }
- Console.WriteLine($"Cool threshold: {threshold}");
- Console.WriteLine($"{matchesValidEmojies.Count} emojis found in the text. The cool ones are: ");
- Console.WriteLine(string.Join(Environment.NewLine,listCoolEmojies));
- }
- }
- }
Add Comment
Please, Sign In to add comment