Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace Arriving_in_Kathmandu
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- string pattern = @"^(?<name>[A-Za-z0-9!@#$?]+)=(?<length>[\d]+)<<(?<code>.+)$";
- StringBuilder nameToPrint = new StringBuilder();
- while (command!="Last note")
- {
- Match match = Regex.Match(command, pattern);
- string name = match.Groups["name"].Value;
- int length =0;
- string code = "";
- if (name.Length!=0)
- {
- length = int.Parse(match.Groups["length"].Value);
- code = match.Groups["code"].Value;
- if (length != code.Length)
- {
- Console.WriteLine("Nothing found!");
- }
- if (length == code.Length)
- {
- for (int i = 0; i < name.Length; i++)
- {
- int letter = name[i];
- if (letter!=33 && letter!=64 && letter!=35 && letter!= 36 && letter!=63)
- {
- nameToPrint.Append(name[i]);
- }
- }
- Console.WriteLine($"Coordinates found! {nameToPrint} -> {code}");
- }
- }
- else
- {
- Console.WriteLine("Nothing found!");
- }
- command = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement