Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Emoji_Sumator
- {
- class Program
- {
- static void Main(string[] args)
- {
- string line = Console.ReadLine();
- //string[] lineSplit = line.Split(" :");
- string emojiCode = Console.ReadLine();
- string[] emojiCodeSplit = emojiCode.Split(":");
- List<string> emojiFound = new List<string>();
- for (int i = 1; i < line.Length; i++)
- {
- string emoji = string.Empty;
- if (line[i] == ':' && line[i-1] == ' ')
- {
- for (int j = i + 1; j < line.Length; j++)
- {
- if (line[j] >= 97 && line[j] <= 122)
- {
- emoji += line[j];
- }
- else if (line[j] == ':' && j+1 < line.Length &&
- (line[j + 1] == ' ' || line[j+1] == ',' || line[j + 1] == '.' || line[j + 1] == '!' || line[j + 1] == '?'))
- {
- if (emoji.Length >= 4)
- {
- emoji = ":" + emoji + ":";
- emojiFound.Add(emoji);
- }
- }
- else
- {
- break;
- }
- i = j;
- }
- }
- }
- int totalPower = 0;
- string emojiInputName = string.Empty;
- foreach (var ch in emojiCodeSplit)
- {
- emojiInputName += (char)int.Parse(ch);
- }
- emojiInputName = ":" + emojiInputName + ":";
- foreach (var emoji in emojiFound)
- {
- int currentEmojiPower = 0;
- for (int i = 1; i < emoji.Length -1; i++)
- {
- currentEmojiPower += (int)emoji[i];
- }
- totalPower += currentEmojiPower;
- }
- if (emojiFound.Contains(emojiInputName))
- {
- totalPower *= 2;
- }
- if (emojiFound.Count > 0)
- {
- Console.WriteLine("Emojis found: " + String.Join(", ", emojiFound));
- }
- Console.WriteLine($"Total Emoji Power: {totalPower}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement