Advertisement
obedmarsh

03. Rage Quit

Aug 15th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 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.  
  7. namespace Extended
  8. {
  9.  
  10.     class Program
  11.     {
  12.  
  13.             static StringBuilder sb = new StringBuilder();
  14.         public static void Main(string[] args)
  15.         {
  16.             string reg = @"(?<text>\D+)(?<count>\d+)";
  17.             var input = Console.ReadLine();
  18.             var match = Regex.Matches(input, reg);
  19.             foreach (Match item in match)
  20.             {
  21.                 string text = item.Groups["text"].Value;
  22.                 int count = int.Parse(item.Groups["count"].Value);
  23.                 Repeat(text, count);
  24.             }
  25.             string res = sb.ToString().ToUpper();
  26.             Console.WriteLine("Unique symbols used: {0}", res.Distinct().Count());
  27.             Console.WriteLine(res);
  28.  
  29.         }
  30.         private static void Repeat(string text, int repeatCount)
  31.         {
  32.             for (int i = 0; i < repeatCount; i++)
  33.             {
  34.                 sb.Append(text);
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement