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 _03.RageQuit
- {
- class RageQuit
- {
- static void Main()
- {
- string text = Console.ReadLine();
- //var pairs = new Dictionary<string, int>();
- var uniqueSymbols = new HashSet<char>();
- StringBuilder result = new StringBuilder();
- Regex pattern = new Regex(@"(?<string>[^0-9]+)(?<number>[0-9]+)");
- MatchCollection matches = pattern.Matches(text);
- foreach (Match match in matches)
- {
- string str = match.Groups["string"].ToString();
- str = str.ToUpper();
- int number = int.Parse(match.Groups["number"].ToString());
- for (int cnt = 0; cnt < number; cnt++)
- {
- result.Append(str);
- foreach (var symbol in str)
- {
- uniqueSymbols.Add(symbol);
- }
- }
- }
- Console.WriteLine("Unique symbols used: {0}", uniqueSymbols.Count());
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment