Advertisement
tanya_zheleva

Rage Quit

Feb 22nd, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  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. HashSet<string> uniqueSymbols = new HashSet<string>();
  14. string pattern = @"(([^\d]+)(\d+))";
  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. for (int i = 0; i < message.Length; i++)
  31. {
  32. uniqueSymbols.Add(message[i].ToString().ToUpper());
  33. }
  34. }
  35.  
  36. Console.WriteLine($"Unique symbols used: {uniqueSymbols.Count}");
  37. Console.WriteLine(output);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement