SHARE
TWEET

Final Exam/Arriving in Kathmandu

gospod1978 Oct 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.  
  7. namespace fundamental14
  8. {
  9.     class MainClass
  10.     {
  11.         public static void Main()
  12.         {
  13.             string input = string.Empty;
  14.             string pattern = @"^([A-Za-z0-9\!\@\#\$\?]+)=(\d+)<<([A-Za-z0-9]+)$";
  15.  
  16.             while ((input = Console.ReadLine()) != "Last note")
  17.             {
  18.                 Match match = Regex.Match(input, pattern);
  19.  
  20.                 if (match.Success)
  21.                 {
  22.                     string name = match.Groups[1].Value;
  23.                     int lenght = int.Parse(match.Groups[2].Value);
  24.                     string geohasCode = match.Groups[3].Value;
  25.  
  26.                     if (lenght == geohasCode.Length)
  27.                     {
  28.                         var nameOfMountain = new String(name.Where(Char.IsLetterOrDigit).ToArray());
  29.  
  30.                         Console.WriteLine($"Coordinates found! {nameOfMountain} -> {geohasCode}");
  31.                     }
  32.                     else
  33.                     {
  34.                         Console.WriteLine("Nothing found!");
  35.                     }
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine("Nothing found!");
  40.                 }
  41.             }
  42.         }
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top