Guest User

Untitled

a guest
Feb 7th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace p03_RageQuit //https://judge.softuni.bg/Contests/Practice/DownloadResource/1655
  7. {
  8. class p03_RageQuit
  9. {
  10. static void Main(string[] args)
  11. {
  12. var input = Console.ReadLine().ToUpper();
  13.  
  14. var numbers = input.Where(c => char.IsDigit(c)).ToList();
  15.  
  16. var uniqueSymbols = Regex.Replace(input, @"[\d-]", string.Empty)
  17. .Distinct()
  18. .Count();
  19.  
  20. var strings = Regex.Split(input, @"\d+").ToList(); //get strings - ASD, &, S@
  21.  
  22. var output = new List<string>();
  23.  
  24. for (int i = 0; i < numbers.Count; i++)
  25. {
  26. for (int j = 0; j < int.Parse(numbers[i].ToString()); j++)
  27. {
  28. output.Add(strings[i]);
  29. }
  30. }
  31.  
  32. Console.WriteLine($"Unique symbols used: {uniqueSymbols}");
  33. Console.WriteLine(string.Join("", output));
  34.  
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment