Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Text;
- public class Program
- {
- public static void Main()
- {
- string input = Console.ReadLine().ToUpper();
- StringBuilder result = new StringBuilder();
- string pattern = @"((?<letters>[\D]+)(?<num>\d+))";
- MatchCollection matches = Regex.Matches(input,pattern);
- foreach (Match match in matches)
- {
- string letters = match.Groups["letters"].Value;
- int num = int.Parse(match.Groups["num"].Value);
- for (int i=0; i<num; i++)
- {
- result.Append(letters);
- }
- }
- int symbols = result.ToString().Distinct().Count();
- Console.WriteLine("Unique symbols used: {0}",symbols);
- Console.WriteLine(result.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment