Advertisement
AlexVanchov

Rage_Quit

Nov 27th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace Rage_Quit_v3._0
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Regex pattern = new Regex(@"(\D+)(\d+)");
  13.             string input = Console.ReadLine().ToUpper();
  14.             var result = new List<string>();
  15.             var charsUsed = new List<char>();
  16.             int counter = 0;
  17.             foreach (Match item in pattern.Matches(input))
  18.             {
  19.                 int count = int.Parse(item.Groups[2].Value);
  20.                 string word = item.Groups[1].Value;
  21.                 for (int i = 0; i < count; i++) result.Add(word);
  22.                 foreach (char Char in item.Groups[1].Value)
  23.                 {
  24.                     if (!charsUsed.Contains(Char))
  25.                     {
  26.                         charsUsed.Add(Char);
  27.                         counter++;
  28.                     }
  29.                 }
  30.             }
  31.             Console.WriteLine($"Unique symbols used: {counter}");
  32.             Console.WriteLine(string.Join("", result));
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement