Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace solutions
- {
- class one
- {
- static void Main()
- {
- var patern = @"^(?<peak>[A-Za-z0-9!@#$?]+)=(?<length>\d+)<<(?<code>.+)$";
- while (true)
- {
- var input = Console.ReadLine();
- if (input == "Last note")
- {
- break;
- }
- else
- {
- if (Regex.Match(input, patern).Success)
- {
- foreach (Match item in Regex.Matches(input, patern))
- {
- var name = "";
- var length = int.Parse(item.Groups["length"].Value);
- var code = item.Groups["code"].Value;
- if (length == code.Length)
- {
- foreach (var m in item.Groups["peak"].Value)
- {
- if (char.IsLetterOrDigit(m))
- {
- name += m;
- }
- }
- Console.WriteLine($"Coordinates found! {name} -> {code}");
- }
- else
- {
- Console.WriteLine("Nothing found!");
- }
- }
- }
- else
- {
- Console.WriteLine("Nothing found!");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement