Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Regex
- {
- using System;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Regex regex = new Regex(@"([:|*]{2})(?<emoji>[A-Z][a-z]{2,})\1");
- MatchCollection result = regex.Matches(input);
- List<string> coolEmoji = new List<string>();
- foreach (Match item in result)
- {
- coolEmoji.Add(item.ToString());
- }
- Regex digit = new Regex("[0-9]");
- MatchCollection totoalDigit = digit.Matches(input);
- long thresHoldSum = 1;
- foreach (var d in totoalDigit)
- {
- thresHoldSum *= int.Parse(d.ToString());
- }
- var badEmojis = new List<string>();
- foreach (var item in coolEmoji)
- {
- int sum = 0;
- string tempItem = item;
- tempItem.Trim(':');
- tempItem.Trim('*');
- foreach (var letter in tempItem) sum += letter;
- if (sum < thresHoldSum)
- {
- badEmojis.Add(item);
- }
- }
- coolEmoji = coolEmoji.Where(x => !badEmojis.Contains(x)).ToList();
- Console.WriteLine($"Cool threshold: {thresHoldSum}");
- Console.WriteLine($"{result.Count} emojis found in the text. The cool ones are:");
- foreach (var emoji in coolEmoji)
- {
- Console.WriteLine($"{emoji}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement