Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Emoji_Sumator
- {
- class Program
- {
- static void Main(string[] args)
- {
- Regex regex = new Regex(@"(?<=[\s])(?<emoji>:[a-z]{4,}:)(?=[\s,.!?])");
- string givenMessage = Console.ReadLine();
- int[] emojiCodeArr = Console.ReadLine().Split(":").Select(int.Parse).ToArray();
- string emojiName = "";
- for (int i = 0; i < emojiCodeArr.Length; i++)
- {
- char curSymbol = (char)emojiCodeArr[i];
- emojiName += curSymbol;
- }
- int totalPower = 0;
- MatchCollection matchCollection = regex.Matches(givenMessage);
- foreach (var match in matchCollection)
- {
- string calcMatch = match.ToString();
- for (int i = 1; i < calcMatch.Length - 1; i++)
- {
- totalPower += calcMatch[i];
- }
- }
- foreach (var match in matchCollection)
- {
- string tempMatch = match.ToString();
- string tempEmojiName = tempMatch.Remove(0, 1);
- tempEmojiName = tempEmojiName.Remove(tempEmojiName.Length - 1, 1);
- if (tempEmojiName == emojiName)
- {
- totalPower *= 2;
- break;
- }
- }
- //if (string.Join("", matchCollection).Contains(emojiName))
- //{
- // totalPower *= 2;
- //}
- if (matchCollection.Count > 0)
- {
- Console.WriteLine($"Emojis found: {string.Join(", ", matchCollection)}");
- }
- Console.WriteLine($"Total Emoji Power: {totalPower}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement