Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace _2._Emoji_Detector
- {
- class Program
- {
- static void Main(string[] args)
- {
- string digitPattern = @"[2-9]";
- string emojiPattern = @"((::)|(\*\*))([A-Z][a-z]{2,})\1";
- ulong threshold = 1;
- ulong emojiSum = 0;
- List<string> result = new List<string>();
- string text = Console.ReadLine();
- Regex regDigit = new Regex(digitPattern);
- Regex regEmoj = new Regex(emojiPattern);
- var matchRegDigit = regDigit.Matches(text);
- var matchRegEmoj = regEmoj.Matches(text);
- int emojiCount = matchRegEmoj.Count;
- foreach (Match item in matchRegDigit)
- {
- ulong digit = ulong.Parse(item.Groups[0].Value);
- threshold = threshold * digit;
- }
- foreach (Match item in matchRegEmoj)
- {
- string emoji = item.Groups[4].Value;
- string fullEmoji = item.Groups[0].Value;
- for (int i = 0; i < emoji.Length; i++)
- {
- emojiSum += emoji[i];
- }
- if (emojiSum > threshold)
- {
- result.Add(fullEmoji);
- }
- emojiSum = 0;
- }
- Console.WriteLine($"Cool threshold: {threshold}");
- Console.WriteLine($"{emojiCount} emojis found in the text. The cool ones are:");
- foreach (var item in result)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment