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;
- using System.Text.RegularExpressions;
- namespace _2.Emoji_Sumator
- {
- class Program
- {
- static void Main(string[] args)
- {
- string theText = Console.ReadLine();
- var emojiCode = Console.ReadLine().Split(':').Select(int.Parse).ToList();
- var myRegEx = new Regex(@" (:[a-z]{4,}:)[,.?! ]");
- var listOfEmojis = new List<string>();
- int totalEmojiPoints = 0;
- var isMatch = myRegEx.IsMatch(theText);
- StringBuilder newStrBuild = new StringBuilder();
- for (int i = 0; i < emojiCode.Count; i++)
- {
- newStrBuild.Append((char)emojiCode[i]);
- }
- if (isMatch)
- {
- var matches = myRegEx.Matches(theText);
- foreach (Match emojis in matches)
- {
- listOfEmojis.Add(emojis.Groups[1].Value);
- }
- for (int i = 0; i < listOfEmojis.Count; i++)
- {
- string theEmoji = listOfEmojis[i];
- for (int k = 0; k < theEmoji.Length; k++)
- {
- if (char.IsLetter(theEmoji[k]))
- {
- totalEmojiPoints += (int)theEmoji[k];
- }
- }
- }
- }
- for (int i = 0; i < listOfEmojis.Count; i++)
- {
- if (listOfEmojis[i].Contains(newStrBuild.ToString()))
- {
- totalEmojiPoints *= 2;
- break;
- }
- }
- if (listOfEmojis.Count > 0)
- {
- Console.WriteLine("Emojis found: " + string.Join(", ", listOfEmojis));
- }
- Console.WriteLine($"Total Emoji Power: {totalEmojiPoints}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement