VD_Iordanov

DestinationMapper

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