Advertisement
parunowaa

02.Destination_Mapper

Dec 11th, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _02.Destination_Mapper
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Regex regex = new Regex(@"([=\/])([A-Z][A-Za-z]{2,})\1");
  11.            
  12.             string input = Console.ReadLine();
  13.             var matches = regex.Matches(input);
  14.            
  15.             Console.Write($"Destinations: ");
  16.            
  17.             int travelPoints = 0;
  18.             int indexOfMatches = 0;
  19.            
  20.             foreach (Match match in matches)
  21.             {
  22.                 indexOfMatches++;
  23.                 Console.Write($"{match.Groups[2].Value}");
  24.                 travelPoints += match.Groups[2].Value.Length;
  25.                 if (indexOfMatches < matches.Count)
  26.                 {
  27.                     Console.Write(", ");
  28.                 }
  29.             }
  30.             Console.WriteLine();
  31.             Console.WriteLine($"Travel Points: {travelPoints}");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement