Advertisement
knoteva

2. Rage Quit

Jul 30th, 2019
158
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.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();
  16.             MatchCollection matched = Regex.Matches(input, regex);
  17.             var sb = new StringBuilder();
  18.             var set = new HashSet<char>();
  19.  
  20.             foreach (Match m in matched)
  21.             {
  22.                 var str = m.Groups["str"].Value.ToUpper();
  23.                 foreach (var ch in str)
  24.                 {
  25.                         set.Add(ch);                          
  26.                 }
  27.                 var repeat = int.Parse(m.Groups["repeat"].Value);
  28.  
  29.                 for (int i = 0; i < repeat; i++)
  30.                 {
  31.                     sb.Append(str);
  32.                 }
  33.             }
  34.  
  35.             Console.WriteLine($"Unique symbols used: {sb.ToString().Distinct().Count()}");
  36.             Console.WriteLine(sb);
  37.            
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement