LardaX

Rage-Quit

Oct 19th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 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 Rage_Quit
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string input = Console.ReadLine().ToUpper();
  15.             string pattern = "(\\D+)(\\d+)";
  16.  
  17.             StringBuilder output = new StringBuilder();
  18.  
  19.             Regex regex = new Regex(pattern);
  20.             MatchCollection matches = regex.Matches(input);
  21.  
  22.             foreach (Match match in matches)
  23.             {
  24.                 string symbols = match.Groups[1].ToString();
  25.                 int count = int.Parse(match.Groups[2].ToString());
  26.  
  27.                 for (int i = 0; i < count; i++)
  28.                 {
  29.                     output.Append(symbols);
  30.                 }
  31.             }
  32.  
  33.             int uniqueSym = output.ToString().Distinct().Count();
  34.  
  35.             Console.WriteLine($"Unique symbols used: {uniqueSym}");
  36.             Console.WriteLine(output);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment