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