Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace Problem10RageQuit
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string regex = @"(?<value>[^0-9]+)(?<times>[0-9]+)";
- MatchCollection matched = Regex.Matches(input, regex);
- StringBuilder result = new StringBuilder();
- foreach (Match match in matched)
- {
- var value = match.Groups["value"].Value;
- var times = int.Parse(match.Groups["times"].Value);
- for (int i = 0; i < times; i++)
- {
- result.Append(value.ToUpper());
- }
- }
- int uniqueSymbolsCount = result.ToString().Distinct().Count();
- Console.WriteLine($"Unique symbols used: {uniqueSymbolsCount}");
- Console.WriteLine(result);
- }
- }
- }
Add Comment
Please, Sign In to add comment