Advertisement
nikolayneykov

Untitled

Apr 10th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. class Program
  7. {
  8.     static void Main(string[] args)
  9.     {
  10.         var regex = new Regex(@"(?<=\s|^)(:[a-z]{4,}:)(?=[,.!?\s]|$)");
  11.         var emojies = regex.Matches(Console.ReadLine()).Select(x => x.Groups[1].Value).ToList();
  12.         var decodedEmoji = $":{string.Join("", Console.ReadLine().Split(":").Select(x => (char)int.Parse(x)))}:";
  13.         var emojiPower = 0;
  14.  
  15.         emojies.ForEach(emoji =>
  16.         {
  17.             emojiPower += emoji.Trim(':').ToCharArray().Select(x => (int)x).Sum();
  18.         });
  19.  
  20.         if (emojies.Count > 0)
  21.         {
  22.             Console.WriteLine($"Emojis found: { string.Join(", ", emojies)}");
  23.         }
  24.  
  25.         if (emojies.Any(x => x.Equals(decodedEmoji)))
  26.         {
  27.             emojiPower *= 2;
  28.         }
  29.  
  30.         Console.WriteLine($"Total Emoji Power: {emojiPower}");
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement