Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Linq;
- using System.Diagnostics;
- namespace RageQuit
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stopwatch timer = new Stopwatch();
- timer.Start();
- string pattern = @"(?<stringName>[^0-9]+)(?<count>\d+)";
- string input = Console.ReadLine();
- var match = Regex.Matches(input, pattern);
- var sb = new StringBuilder();
- //int count = 0;
- //string matchedElement = string.Empty;
- foreach (Match item in match)
- {
- string currentSymbol = item.Groups["stringName"].Value;
- int repeatCount = int.Parse(item.Groups["count"].Value);
- for (int i = 0; i < repeatCount; i++)
- {
- sb.Append(currentSymbol);
- }
- //matchedElement += item;
- }
- var result = sb.ToString();
- result = result.ToUpper();
- //matchedElement = matchedElement.ToUpper();
- //string isContains = "";
- //for (int i = 0; i < matchedElement.Length; i++)
- //{
- // char currentSymbol = matchedElement[i];
- // if (!Char.IsDigit(currentSymbol) && !isContains.Contains(currentSymbol))
- // {
- // count++;
- // isContains += currentSymbol;
- // }
- //}
- Console.WriteLine($"Unique symbols used: {result.Distinct().Count()}");
- Console.WriteLine(result);
- timer.Stop();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement