Advertisement
Danny_Berova

03.RageQuit

Aug 14th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1.  
  2. namespace _03.RageQuit
  3. {
  4.     using System;
  5.     using System.Collections.Generic;
  6.     using System.Linq;
  7.     using System.Text;
  8.     using System.Text.RegularExpressions;
  9.  
  10.     public class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.             string pattern = @"(\D+)(\d+)";
  15.             Regex regex = new Regex(pattern);
  16.  
  17.             string inputLine = Console.ReadLine();
  18.  
  19.             var matches = regex.Matches(inputLine);
  20.  
  21.             StringBuilder result = new StringBuilder();
  22.  
  23.             foreach (Match match in matches)
  24.             {
  25.                 string partition = match.Groups[1].Value;
  26.                 int times = int.Parse(match.Groups[2].Value);
  27.  
  28.                 for (int i = 0; i < times; i++)
  29.                 {
  30.                     result.Append(partition.ToUpper());
  31.                 }
  32.             }
  33.  
  34.             int count = result.ToString().Distinct().Count();
  35.  
  36.             Console.WriteLine($"Unique symbols used: {count}");
  37.             Console.WriteLine(result);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement