Advertisement
Guest User

Untitled

a guest
May 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4.  
  5. namespace exam_prep_III_3
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string line = Console.ReadLine();
  12.  
  13.             var regex = "([^0-9]+)(\\d+)";
  14.  
  15.             var matches = Regex.Matches(line, regex);
  16.  
  17.             var strings = string.Join("",matches.Select(x => x.Groups[1].Value).ToArray());
  18.  
  19.             Console.WriteLine($"Unique symbols used: {strings.ToLower().Distinct().Count()}");
  20.  
  21.             foreach (Match match in matches)
  22.             {
  23.                 var text = match.Groups[1].Value;
  24.                 var number = int.Parse(match.Groups[2].Value);
  25.  
  26.                 Console.Write(string.Concat(Enumerable.Repeat(text.ToUpper(), number)));
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement