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;
- using System.Text;
- 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 (var emoji in result)
- {
- coolEmoji.Add(emoji.ToString());
- }
- Regex digit = new Regex("[0-9]");
- MatchCollection totoalDigit = digit.Matches(input);
- List<string> totalSum = new List<string>();
- foreach (var d in totoalDigit)
- {
- totalSum.Add(d.ToString());
- }
- long thresHoldSum = 1;
- for (int i = 0; i < totalSum.Count; i++)
- {
- long currDig = long.Parse(totalSum[i]);
- thresHoldSum *= currDig;
- }
- for (int i = 0; i < coolEmoji.Count; i++)
- {
- long emojiSum = 0;
- string currEmoji = coolEmoji[i];
- for (int u = 0; u < currEmoji.Length; u++)
- {
- if (currEmoji[u] != '*' && currEmoji[u] != ':')
- {
- emojiSum += currEmoji[u];
- }
- }
- if (emojiSum < thresHoldSum)
- {
- coolEmoji.Remove(currEmoji);
- }
- }
- Console.WriteLine($"Cool threshold: {thresHoldSum}");
- if (coolEmoji.Count > 0)
- {
- 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