Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Text;
- namespace ExamPreparation
- {
- public sealed class Preparation
- {
- public static void Main()
- {
- string input = Console.ReadLine();
- HashSet<string> uniqueSymbols = new HashSet<string>();
- string pattern = @"(([^\d]+)(\d+))";
- Regex regex = new Regex(pattern);
- MatchCollection matches = regex.Matches(input);
- StringBuilder output = new StringBuilder();
- foreach (Match match in matches)
- {
- string message = match.Groups[2].Value;
- int repeats = int.Parse(match.Groups[3].Value);
- for (int i = 0; i < repeats; i++)
- {
- output.Append(message.ToUpper());
- }
- for (int i = 0; i < message.Length; i++)
- {
- uniqueSymbols.Add(message[i].ToString().ToUpper());
- }
- }
- Console.WriteLine($"Unique symbols used: {uniqueSymbols.Count}");
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement