Advertisement
YavorGrancharov

Rage_Quit(copy)

Aug 19th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Rage_Quit
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string input = Console.ReadLine().ToUpper();
  12.  
  13.             List<char> result = new List<char>();
  14.             List<char> currResult = new List<char>();
  15.  
  16.             for (int i = 0; i < input.Length; i++)
  17.             {
  18.                 char ch = input[i];
  19.  
  20.                 if (!char.IsNumber(ch))
  21.                 {
  22.                     currResult.Add(ch);
  23.                 }
  24.  
  25.                 if (char.IsNumber(ch))
  26.                 {
  27.                     int count = 0;
  28.                     if (i < input.Length - 1 && char.IsNumber(input[i + 1]))
  29.                     {
  30.                         string str = input.Substring(i, 2);
  31.                         count = int.Parse(str.ToString());
  32.                     }
  33.                     else
  34.                     {
  35.                         count = int.Parse(ch.ToString());
  36.                     }
  37.  
  38.                     if (count > 0)
  39.                     {
  40.                         for (int j = 0; j < count; j++)
  41.                         {
  42.                             result.AddRange(currResult);
  43.                         }
  44.                     }
  45.                     currResult.Clear();
  46.                 }
  47.             }
  48.             string res = new string(result.ToArray());
  49.             Console.WriteLine("Unique symbols used: {0}", res.Distinct().Count());
  50.             Console.WriteLine(res);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement