Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- namespace DestinationMapper
- {
- class Program
- {
- static void Main(string[] args)
- {
- string map = Console.ReadLine();
- Regex regexforPlaces = new Regex(@"(=|\/)(?<place>[A-Z][A-Za-z]{2,})(\1)");
- MatchCollection matchesPlaces = regexforPlaces.Matches(map);
- var listWithPlaces = new List<string>();
- int travelPoints = 0;
- foreach (Match match in matchesPlaces)
- {
- string place = match.Groups["place"].Value;
- listWithPlaces.Add(place);
- int length = place.Length;
- travelPoints += length;
- }
- Console.WriteLine($"Destinations: {string.Join(", ",listWithPlaces)}");
- Console.WriteLine($"Travel Points: {travelPoints}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement