Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace EmojiDetector
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- Dictionary<string, int> dictionary = new Dictionary<string, int>();
- long thresHold = 1;
- for (int i = 0; i < text.Length; i++)
- {
- if (char.IsDigit(text[i]))
- {
- thresHold *= int.Parse(text[i].ToString());
- }
- }
- string emojiPattern = @"([*]{2}|[:]{2})(?<letters>[A-Z][a-z]{2,})\1";
- MatchCollection emojies = Regex.Matches(text, emojiPattern);
- int coolness = 0;
- for (int i = 0; i < emojies.Count; i++)
- {
- string emoji = emojies[i].Groups["letters"].Value;
- for (int j = 0; j < emoji.Length; j++)
- {
- coolness += emoji[j];
- }
- if (!dictionary.ContainsKey(emojies[i].Value))
- {
- dictionary.Add(emojies[i].Value, coolness);
- }
- coolness = 0;
- }
- int countTotalEmojies = dictionary.Count;
- dictionary = dictionary.Where(x => x.Value > thresHold).ToDictionary(x => x.Key, x => x.Value);
- Console.WriteLine($"Cool threshold: {thresHold}");
- Console.WriteLine($"{countTotalEmojies} emojis found in the text. The cool ones are:");
- foreach (var item in dictionary)
- {
- Console.WriteLine(item.Key);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment