kvadrat4o

RageQuit

Jul 5th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace RageQuit
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.         string input = Console.ReadLine().ToUpper();
  15.         StringBuilder result = new StringBuilder();
  16.         Regex regex = new Regex(@".*?[0-9]+");
  17.         MatchCollection matches = regex.Matches(input);
  18.         foreach (var match in matches)
  19.         {
  20.             string matchOne = match.ToString();
  21.             int count = int.Parse(Regex.Match(matchOne, "[0-9]+").ToString());
  22.             matchOne = Regex.Replace(matchOne, @"[0-9]", "");
  23.             for (int i = 0; i < count; i++)
  24.             {
  25.                 result.Append(matchOne);
  26.             }
  27.         }
  28.         Console.WriteLine("Unique symbols used: {0}", Unique(input));
  29.         Console.WriteLine(result);
  30.     }
  31.     public static int Unique(string input)
  32.     {
  33.         input = input.ToUpper();
  34.         Regex rgx = new Regex(@"[0-9]");
  35.         input = rgx.Replace(input, "");
  36.         string unique = new String(input.Distinct().ToArray());
  37.         return unique.Length;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment