Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Text;
- namespace apps
- {
- class Program
- {
- static string Get() { return Console.ReadLine(); }
- static int GetInt() { return int.Parse(Console.ReadLine()); }
- static void Main()
- {
- //emoji detector
- string text = Get();
- string pattern = @"([:*]{2})(?<word>[A-Z]{1}[a-z]{3,})\1";
- MatchCollection matches = Regex.Matches(text, pattern);
- List<string> emojis = new List<string>();
- int coolness_threshold = 0;
- foreach (Match m in matches)
- {
- string match = m.ToString();
- match.Trim();
- emojis.Add(match);
- string word = m.Groups["word"].ToString(); //match.All(x => char.IsLetter(x)).ToString() ;
- int total = 0;
- foreach (char c in word)
- {
- int value = (int)c;
- total += value;
- }
- coolness_threshold += total;
- }
- Console.WriteLine($"Cool threshold: {coolness_threshold}");
- Console.WriteLine($"{emojis.Count} emojis found in the text. The cool ones are:");
- Console.WriteLine(string.Join("\n", emojis));
- }
- }
- }// END MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement