Advertisement
svetlyoek

01. Final

Apr 14th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace solutions
  7. {
  8. class one
  9. {
  10. static void Main()
  11. {
  12. var patern = @"^(?<peak>[A-Za-z0-9!@#$?]+)=(?<length>\d+)<<(?<code>.+)$";
  13.  
  14. while (true)
  15. {
  16. var input = Console.ReadLine();
  17.  
  18. if (input == "Last note")
  19. {
  20. break;
  21. }
  22. else
  23. {
  24. if (Regex.Match(input, patern).Success)
  25. {
  26. foreach (Match item in Regex.Matches(input, patern))
  27. {
  28. var name = "";
  29. var length = int.Parse(item.Groups["length"].Value);
  30. var code = item.Groups["code"].Value;
  31. if (length == code.Length)
  32. {
  33. foreach (var m in item.Groups["peak"].Value)
  34. {
  35. if (char.IsLetterOrDigit(m))
  36. {
  37. name += m;
  38. }
  39. }
  40. Console.WriteLine($"Coordinates found! {name} -> {code}");
  41. }
  42. else
  43. {
  44. Console.WriteLine("Nothing found!");
  45. }
  46. }
  47. }
  48. else
  49. {
  50. Console.WriteLine("Nothing found!");
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement