petarkobakov

Destination Mapper

Aug 9th, 2020 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Linq.Expressions;
  7.  
  8. namespace Final_Exam___Destination_Mapper
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string input = Console.ReadLine();
  15. Regex pattern = new Regex(@"(?<opentab>[=]|[\/]{1})(?<destination>[A-Z]{1}[A-z]{2,})(?<closetab>\1)");
  16. MatchCollection destinations = pattern.Matches(input);
  17. List<string> destinationsList = new List<string>();
  18. int travelPoints = 0;
  19. foreach (Match country in destinations)
  20. {
  21. travelPoints += country.Groups["destination"].Length;
  22. destinationsList.Add(country.Groups["destination"].Value);
  23. }
  24.  
  25. Console.WriteLine($"Destinations: {string.Join(", ", destinationsList)}");
  26. Console.WriteLine($"Travel Points: {travelPoints}");
  27. }
  28. }
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment