Advertisement
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;
- class RageQuit
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine().ToUpper();
- StringBuilder result = new StringBuilder();
- string pattern = @".*?[0-9]+";
- Regex regex = new Regex(pattern);
- MatchCollection matches = regex.Matches(input);
- foreach (var match in matches)
- {
- string newMatch = match.ToString();
- int counter = int.Parse(Regex.Match(newMatch, "[0-9]+").ToString());
- newMatch = Regex.Replace(newMatch, @"[0-9]", "");
- for (int i = 0; i < counter; i++)
- {
- result.Append(newMatch);
- }
- }
- Console.WriteLine("Unique symbols used: {0}", CheckUnique(input));
- Console.WriteLine(result);
- }
- public static int CheckUnique(string input)
- {
- input = input.ToUpper();
- Regex rgx = new Regex(@"[0-9]");
- input = rgx.Replace(input, "");
- string unique = new String(input.Distinct().ToArray());
- return unique.Length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement