knoteva

Rage Quit

Jul 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Anonymous_Vox
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string regex = @"(?<str>[^0-9]+)(?<repeat>[0-9]+)";
  15.             string input = Console.ReadLine().ToUpper();
  16.             var matched = Regex.Matches(input, regex);
  17.             var sb = new StringBuilder();
  18.            
  19.  
  20.             foreach (Match m in matched)
  21.             {
  22.  
  23.                 for (int i = 0; i < int.Parse(m.Groups["repeat"].Value); i++)
  24.                 {
  25.                     sb.Append(m.Groups["str"].Value);
  26.                 }
  27.             }
  28.  
  29.             Console.WriteLine($"Unique symbols used: {sb.ToString().Distinct().Count()}");
  30.             Console.WriteLine(sb);
  31.         }
  32.     }
  33. }
Add Comment
Please, Sign In to add comment