Advertisement
reking12

Untitled

Mar 24th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5.  
  6. namespace P10Rage_Quit
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string input = Console.ReadLine();
  13.             string regex = @"([^0-9]+[0-9]+)";
  14.             var matches = Regex.Matches(regex, input);
  15.             string textReg = @"[^0-9]+";
  16.             string numReg = @"[0-9]+";
  17.             var result = new StringBuilder();
  18.  
  19.             foreach (Match match in matches)
  20.             {
  21.                 string strMatch = match.ToString();
  22.                 Match textMatch = Regex.Match(textReg, strMatch);
  23.                 Match numberMatch = Regex.Match(numReg, strMatch);
  24.                 int number = int.Parse(numberMatch.ToString());
  25.  
  26.                 for (int i = 0; i < number; i++)
  27.                 {
  28.                     result.Append(textMatch.ToString());
  29.                 }
  30.             }
  31.             string output = result.ToString().ToUpper();
  32.  
  33.             Console.WriteLine($"Unique symbols used: {output.Distinct().Count()}");
  34.             Console.WriteLine(output);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement