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()
- {
- var input = Console.ReadLine().ToUpper();
- var nonDigits = new StringBuilder();//new List<char>();
- var sb = new StringBuilder();
- //var strings = new List<char>();
- var uniques = Regex.Replace(input, @"[\d]+", "");
- for (int i = 0; i < input.Length; i++)
- {
- if (!char.IsDigit(input[i]))
- {
- nonDigits.Append(input[i]);//nonDigits.Add(input[i])
- }
- else if (char.IsDigit(input[i]))
- {
- var digit = int.Parse(char.GetNumericValue(input[i]).ToString());
- if (i + 1 < input.Length && digit > 0)
- {
- if (char.IsDigit(input[i + 1]))
- {
- var digitTens = char.GetNumericValue(input[i]).ToString();
- var digitOnes = char.GetNumericValue(input[i + 1]).ToString();
- var number = int.Parse(digitTens) * 10 + int.Parse(digitOnes);
- for (int d = 0; d < number; d++)
- {
- //strings.AddRange(nonDigits);
- sb.Append(nonDigits);
- }
- i = i + 1;
- }
- else if (!char.IsDigit(input[i + 1]))
- {
- for (int d = 0; d < digit; d++)
- {
- //strings.AddRange(nonDigits);
- sb.Append(nonDigits);
- }
- }
- }
- else if (i + 1 == input.Length)
- {
- for (int d = 0; d < digit; d++)
- {
- //strings.AddRange(nonDigits);
- sb.Append(nonDigits);
- }
- }
- nonDigits.Clear();
- }
- }
- var count = uniques.ToString().Distinct().ToArray();
- Console.WriteLine("Unique symbols used: {0}", new string(count).Length);
- //Console.WriteLine(string.Join("",strings));
- Console.WriteLine(sb);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement