Advertisement
veno0

Untitled

Apr 5th, 2020
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Reflection.Metadata;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Channels;
  8.  
  9. namespace ConsoleApp8
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             string patternName = @"(?<symbols>[*:]{2})(?<name>[A-Z][a-z]{2,})\1";
  16.             string patternDigits = @"(?<digits>\d)";
  17.  
  18.             string input = Console.ReadLine();
  19.             long coolThreshhold = 1;
  20.             MatchCollection matches = Regex.Matches(input, patternName);
  21.             MatchCollection matchesNumbers = Regex.Matches(input, patternDigits);
  22.             string concatNumbers = string.Empty;
  23.             List<string> cool = new List<string>();
  24.             foreach (var number in matchesNumbers)
  25.             {
  26.                 concatNumbers += number;
  27.  
  28.             }
  29.  
  30.  
  31.             for (int i = 0; i < concatNumbers.Length; i++)
  32.             {
  33.                 coolThreshhold *= int.Parse(concatNumbers[i].ToString());
  34.             }
  35.             foreach (Match match in matches)
  36.             {
  37.  
  38.                 if (match.Success)
  39.                 {
  40.                     long sumASCI = 0;
  41.                     foreach (var symbol in match.Groups["name"].Value)
  42.                     {
  43.                         sumASCI += symbol;
  44.                     }
  45.  
  46.                     if (sumASCI >= coolThreshhold)
  47.                     {
  48.                         string addName = match.Groups["symbols"].Value + match.Groups["name"].Value +
  49.                                          match.Groups["symbols"].Value;
  50.                         cool.Add(addName);
  51.                     }
  52.                 }
  53.            
  54.  
  55.             }
  56.             Console.WriteLine($"Cool threshold: {coolThreshhold}");
  57.             Console.WriteLine($"{matches.Count} emojis found in the text. The cool ones are:");
  58.  
  59.          
  60.                 foreach (var coolnames in cool)
  61.                 {
  62.                     Console.WriteLine($"{coolnames}");
  63.                 }
  64.            
  65.            
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement