Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _01._The_Isle_of_Man_TT_Race
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- string input = Console.ReadLine();
- string regex = @"^([#$%*&])(?<racer>[A-Za-z]+)([#$%*&])=(?<length>[0-9]+)!!(?<geohashCode>.*)";
- MatchCollection matched = Regex.Matches(input, regex);
- if (matched.Count == 0)
- {
- Console.WriteLine("Nothing found!");
- }
- foreach (Match m in matched)
- {
- var racer = m.Groups["racer"].Value;
- var length = m.Groups["length"].Value;
- var geohashCode = m.Groups["geohashCode"].Value;
- if (Convert.ToInt32(length) != geohashCode.Length || m.Groups[1].Value != m.Groups[2].Value)
- {
- Console.WriteLine("Nothing found!");
- }
- else
- {
- string newCode = "";
- for (int i = 0; i < geohashCode.Length; i++)
- {
- newCode += (char)(Convert.ToUInt16(geohashCode[i]) + Convert.ToInt32(length));
- }
- Console.WriteLine($"Coordinates found! {racer} -> {newCode}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement