Advertisement
tanya_zheleva

Rage Quit

Feb 22nd, 2017
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5.  
  6. namespace ExamPreparation
  7. {
  8. public sealed class Preparation
  9. {
  10. public static void Main()
  11. {
  12. string input = Console.ReadLine();
  13. string pattern = @"(([^\d]+)(\d+))";
  14. int count = 0;
  15.  
  16. Regex regex = new Regex(pattern);
  17. MatchCollection matches = regex.Matches(input);
  18. StringBuilder output = new StringBuilder();
  19.  
  20. foreach (Match match in matches)
  21. {
  22. string message = match.Groups[2].Value;
  23. int repeats = int.Parse(match.Groups[3].Value);
  24.  
  25. for (int i = 0; i < repeats; i++)
  26. {
  27. output.Append(message.ToUpper());
  28. }
  29. }
  30.  
  31. count = output.ToString().Distinct().Count();
  32.  
  33. Console.WriteLine($"Unique symbols used: {count}");
  34. Console.WriteLine(output);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement