Advertisement
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 _2._Emoji_Detector
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- var coolEmojis = new List<string>();
- string firstPattern = @"(?<numbers>[\d])";
- string secondPattern = @"([:*]{2})(?<emojiName>[A-Z][a-z]{2,})\1";
- int result = 1;
- MatchCollection matchedNums = Regex.Matches(text, firstPattern);
- foreach (Match match in matchedNums)
- {
- result *= int.Parse(match.Value);
- }
- MatchCollection matchedEmojis = Regex.Matches(text, secondPattern);
- int emojisCount = 0;
- int singleEmojisum = 0;
- Console.WriteLine($"Cool threshold: {result}");
- foreach (Match match in matchedEmojis)
- {
- emojisCount++;
- }
- foreach (Match match in matchedEmojis)
- {
- for (int i = 0; i < match.Length; i++)
- {
- singleEmojisum += (int)match.Value[i];
- }
- if (singleEmojisum > result)
- {
- coolEmojis.Add(match.Value);
- }
- singleEmojisum = 0;
- }
- Console.WriteLine($"{emojisCount} emojis found in the text. The cool ones are: ");
- Console.WriteLine(String.Join(Environment.NewLine, coolEmojis));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement