Advertisement
Krum_50

Emodji Detector

Aug 6th, 2021
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Emoji_Detector
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string line = Console.ReadLine();
  11.             int coolThreshold = 1;
  12.             string currentEmodji = "";
  13.             int coolness = 0; ;
  14.             List<string> validEmojis = new List<string>();
  15.             List<string> coolEmodjis = new List<string>();
  16.             for (int i = 0; i < line.Length; i++)
  17.             {
  18.                 if (Char.IsDigit(line[i]))
  19.                 {
  20.                     coolThreshold *= int.Parse(line[i].ToString());
  21.  
  22.                 }
  23.             }
  24.             Console.WriteLine($"Cool threshold: {coolThreshold}");
  25.             for (int i = 0; i < line.Length - 1; i++)
  26.             {
  27.                 if ((line[i] == '*') || (line[i] == ':'))
  28.                 {
  29.                     if (line[i] == '*')
  30.                     {
  31.                         if (line[i + 1] == '*')
  32.                         {
  33.                             for (int j = i + 2; j < line.Length - 1; j++)
  34.                             {
  35.                                 if (line[j] == '*')
  36.                                 {
  37.                                     if (line[j + 1] == '*')
  38.                                     {
  39.                                         currentEmodji = line.Substring(i, j + 2 - i);
  40.                                         if ((currentEmodji[2] >= 65) && (currentEmodji[2] <= 90))
  41.                                         {
  42.                                             validEmojis.Add(currentEmodji);
  43.                                             i = j + 2;
  44.                                             break;
  45.                                         }
  46.                                         else
  47.                                         {
  48.                                             i = j + 2;
  49.                                             break;
  50.                                         }
  51.                                     }
  52.                                 }
  53.                             }
  54.                         }
  55.                     }
  56.                     if (line[i] == ':')
  57.                     {
  58.                         if (line[i + 1] == ':')
  59.                         {
  60.                             for (int j = i + 2; j < line.Length - 1; j++)
  61.                             {
  62.                                 if (line[j] == ':')
  63.                                 {
  64.                                     if (line[j + 1] == ':')
  65.                                     {
  66.                                         currentEmodji = line.Substring(i, j + 2 - i);
  67.                                         if ((currentEmodji[2] >= 65) && (currentEmodji[2] <= 90))
  68.                                         {
  69.                                             validEmojis.Add(currentEmodji);
  70.                                             i = j + 2;
  71.                                             break;
  72.                                         }
  73.                                         else
  74.                                         {
  75.                                             i = j + 2;
  76.                                         }
  77.                                     }
  78.  
  79.                                 }
  80.                             }
  81.                         }
  82.                     }
  83.                 }
  84.             }
  85.             Console.WriteLine($"{validEmojis.Count} emojis found in the text. The cool ones are:");
  86.             foreach (string Emodji in validEmojis)
  87.             {
  88.                 for (int i = 2; i < Emodji.Length - 2; i++)
  89.                 {
  90.                     if (Char.IsLetter(Emodji[i]))
  91.                     {
  92.                         coolness += Emodji[i];
  93.                     }
  94.                 }
  95.                 if (coolness >= coolThreshold)
  96.                 {
  97.                     coolEmodjis.Add(Emodji);
  98.  
  99.                 }
  100.                 coolness = 0;
  101.             }
  102.             foreach (var coolEmodji in coolEmodjis)
  103.             {
  104.                 Console.WriteLine(coolEmodji);
  105.             }
  106.         }
  107.     }
  108. }
  109.  
  110.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement