Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Linq;
- namespace EmojiDetector
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- Regex emojies = new Regex(@"([\*][\*]|[\:][\:])(?<emoji>[A-Z][a-z]{2,})\1");
- Regex numbers = new Regex(@"\d");
- List<string> coolThreshold = new List<string>();
- long numberResult = 1;
- MatchCollection validEmoji = emojies.Matches(text);
- MatchCollection validNumbers = numbers.Matches(text);
- foreach (Match number in validNumbers)
- {
- long currNumber = long.Parse(number.ToString());
- numberResult *= currNumber;
- }
- foreach (Match emoji in validEmoji)
- {
- string currEmoji = emoji.Groups["emoji"].Value;
- long emojiResult = 0;
- for (int i = 0; i < currEmoji.Length; i++)
- {
- int asciiValue = currEmoji[i];
- emojiResult += asciiValue;
- }
- if (emojiResult >= numberResult)
- {
- coolThreshold.Add(emoji.ToString());
- }
- }
- Console.WriteLine($"Cool threshold: {numberResult}");
- Console.WriteLine($"{validEmoji.Count} emojis found in the text. The cool ones are:");
- Console.WriteLine($"{string.Join(" \n", coolThreshold)}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement