Advertisement
veno0

Untitled

Apr 4th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. string patternName = @"(?<symbols>[*:]{2})(?<name>[A-Z][a-z]{2,})\1";
  2.             string patternDigits = @"(?<digits>\d)";
  3.  
  4.             string input = Console.ReadLine();
  5.             BigInteger coolThreshhold = 1;
  6.             MatchCollection matches = Regex.Matches(input, patternName);
  7.             MatchCollection matchesNumbers = Regex.Matches(input, patternDigits);
  8.             string concatNumbers = string.Empty;
  9.             List<string> cool = new List<string>();
  10.             foreach (var number in matchesNumbers)
  11.             {
  12.                 concatNumbers += number;
  13.  
  14.             }
  15.  
  16.  
  17.             for (int i = 0; i < concatNumbers.Length; i++)
  18.             {
  19.                 coolThreshhold *= int.Parse(concatNumbers[i].ToString());
  20.             }
  21.             foreach (Match match in matches)
  22.             {
  23.  
  24.                 if (match.Success)
  25.                 {
  26.                     BigInteger sumASCI = 0;
  27.                     foreach (var symbol in match.Groups["name"].Value)
  28.                     {
  29.                         sumASCI += symbol;
  30.                     }
  31.  
  32.                     if (sumASCI >= coolThreshhold)
  33.                     {
  34.                         string addName = match.Groups["symbols"].Value + match.Groups["name"].Value +
  35.                                          match.Groups["symbols"].Value;
  36.                         cool.Add(addName);
  37.                     }
  38.                 }
  39.  
  40.  
  41.             }
  42.             Console.WriteLine($"Cool threshold: {coolThreshhold}");
  43.             Console.WriteLine($"{matches.Count} emojis found in the text. The cool ones are:");
  44.  
  45.  
  46.             foreach (var coolnames in cool)
  47.             {
  48.                 Console.WriteLine($"{coolnames}");
  49.             }
  50.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement