Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace _03.RageQuit
  6. {
  7. public class RageQuit
  8. {
  9. public static void Main()
  10. {
  11. var input = Console.ReadLine().ToUpper();
  12. var sb = new StringBuilder();
  13. var uniqueSymbols = new HashSet<char>();
  14. var result = new List<string>();
  15.  
  16. for (int i = 0; i < input.Length; i++)
  17. {
  18. var curChar = input[i];
  19. if (!char.IsNumber(input[i]))
  20. {
  21. uniqueSymbols.Add(input[i]);
  22. sb.Append(input[i]);
  23. }
  24.  
  25. else
  26. {
  27. var num = 0;
  28.  
  29. if (i.Equals(input.Length - 1))
  30. {
  31. num = int.Parse(input[i].ToString());
  32. }
  33.  
  34. else
  35. {
  36. if (!char.IsNumber(input[i + 1]))
  37. {
  38. num = int.Parse(input[i].ToString());
  39. }
  40. else
  41. {
  42. num = int.Parse(input[i] + input[i + 1].ToString());
  43. i += 1;
  44. }
  45.  
  46. }
  47. for (int j = 0; j < num; j++)
  48. {
  49. result.Add(sb.ToString());
  50. }
  51. sb.Clear();
  52. }
  53. }
  54. Console.WriteLine($"Unique symbols used: {uniqueSymbols.Count}");
  55. var printResult = string.Join("", result);
  56. Console.WriteLine(printResult);
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement