Guest User

DestinationMapper

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