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;
- using System.Threading.Tasks;
- namespace _03_RageQuit
- {
- class Program
- {
- static void Main(string[] args)
- {
- var inputString = Console.ReadLine();
- var uniqueString = new List<string>();
- for (int i = 0; i < inputString.Length; i++)
- {
- var currentChar = inputString[i].ToString().ToUpper();
- var num = -1;
- if (!int.TryParse(currentChar.ToString(), out num))
- {
- uniqueString.Add(currentChar);
- }
- }
- uniqueString = uniqueString.Distinct().ToList();
- var pattern = @"([^\d]+)(\d{1,2})";
- var regex = new Regex(pattern);
- var matches = regex.Matches(inputString);
- var sb = new StringBuilder();
- foreach (Match match in matches)
- {
- var currentString = match.Groups[1].Value.ToUpper();
- var currentCount = int.Parse(match.Groups[2].Value);
- if (currentCount <= 20)
- {
- for (int i = 0; i < currentCount; i++)
- {
- sb.Append(currentString);
- }
- }
- }
- Console.WriteLine($"Unique symbols used: {uniqueString.Count}");
- Console.WriteLine(sb.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment