Advertisement
NonaG

RageQuit90/100

Feb 12th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. class RageQuit
  9. {
  10. static void Main()
  11. {
  12. var input = Console.ReadLine().ToUpper();
  13. var nonDigits = new StringBuilder();//new List<char>();
  14. var sb = new StringBuilder();
  15. //var strings = new List<char>();
  16. var uniques = Regex.Replace(input, @"[\d]+", "");
  17. for (int i = 0; i < input.Length; i++)
  18. {
  19. if (!char.IsDigit(input[i]))
  20. {
  21. nonDigits.Append(input[i]);//nonDigits.Add(input[i])
  22. }
  23. else if (char.IsDigit(input[i]))
  24. {
  25. var digit = int.Parse(char.GetNumericValue(input[i]).ToString());
  26. if (i + 1 < input.Length && digit > 0)
  27. {
  28. if (char.IsDigit(input[i + 1]))
  29. {
  30. var digitTens = char.GetNumericValue(input[i]).ToString();
  31. var digitOnes = char.GetNumericValue(input[i + 1]).ToString();
  32. var number = int.Parse(digitTens) * 10 + int.Parse(digitOnes);
  33. for (int d = 0; d < number; d++)
  34. {
  35. //strings.AddRange(nonDigits);
  36. sb.Append(nonDigits);
  37. }
  38. i = i + 1;
  39. }
  40. else if (!char.IsDigit(input[i + 1]))
  41. {
  42. for (int d = 0; d < digit; d++)
  43. {
  44. //strings.AddRange(nonDigits);
  45. sb.Append(nonDigits);
  46. }
  47. }
  48. }
  49. else if (i + 1 == input.Length)
  50. {
  51. for (int d = 0; d < digit; d++)
  52. {
  53. //strings.AddRange(nonDigits);
  54. sb.Append(nonDigits);
  55. }
  56. }
  57. nonDigits.Clear();
  58. }
  59. }
  60. var count = uniques.ToString().Distinct().ToArray();
  61. Console.WriteLine("Unique symbols used: {0}", new string(count).Length);
  62. //Console.WriteLine(string.Join("",strings));
  63. Console.WriteLine(sb);
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement