Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using System.Text;
- namespace _2._Rage_Quit
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine().ToUpper();
- var strBuilder = new StringBuilder();
- MatchCollection allSymbolsWithoutDigits = Regex.Matches(text, @"\D");
- foreach (Match symbol in allSymbolsWithoutDigits)
- {
- strBuilder.Append(symbol.Value);
- }
- string output = strBuilder.ToString().ToUpper();
- int uniqueSymbolsCount = output.Distinct().Count();
- Console.WriteLine($"Unique symbols used: {uniqueSymbolsCount}");
- strBuilder = new StringBuilder();
- var dataWithoutDigits = Regex.Matches(text, @"(?<symbols>\D+)(?<count>\d+)");
- foreach (Match match in dataWithoutDigits)
- {
- string currentSymbolGroup = match.Groups["symbols"].Value;
- int countOfRepeats = int.Parse(match.Groups["count"].Value);
- for (int i = 0; i < countOfRepeats; i++)
- {
- strBuilder.Append(currentSymbolGroup);
- }
- }
- Console.WriteLine(strBuilder);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment