Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using System.Linq;
- namespace RageQuit
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine().ToUpper();
- Regex regexForSymbolsAndNumber = new Regex(@"(.+?)([0-9]+)");
- MatchCollection matchesSymbolsAndNumbers = regexForSymbolsAndNumber.Matches(input);
- StringBuilder sb = new StringBuilder();
- foreach (Match item in matchesSymbolsAndNumbers)
- {
- string symbols = item.Groups[1].Value;
- string number = item.Groups[2].Value;
- int numberInt = int.Parse(number);
- if (numberInt > 0)
- {
- for (int i = 0; i < numberInt; i++)
- {
- sb.Append(symbols);
- }
- }
- }
- int numberUniqueSymbols = sb.ToString().Distinct().Count();
- Console.WriteLine($"Unique symbols used: {numberUniqueSymbols}");
- Console.WriteLine(sb);
- }
- }
- }
Add Comment
Please, Sign In to add comment