Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- namespace _3_Threasure_Finder
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] key = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- while (true)
- {
- string text = Console.ReadLine();
- if (text == "find")
- {
- break;
- }
- int keyCounter = 0;
- string newSequence = string.Empty;
- for (int i = 0; i < text.Length; i++)
- {
- int charNum = text[i] - key[keyCounter];
- newSequence += (char)charNum;
- keyCounter++;
- if (keyCounter == key.Length)
- {
- keyCounter = 0;
- }
- }
- int startTypeIndex = newSequence.IndexOf("&") + 1;
- int endTypeIndex = newSequence.LastIndexOf("&");
- string treasureType = newSequence
- .Substring(startTypeIndex, endTypeIndex - startTypeIndex);
- int startCordinationsIndex = newSequence.IndexOf("<") + 1;
- int endCordinationsIndex = newSequence.LastIndexOf(">");
- string treasureCordinates = newSequence
- .Substring(startCordinationsIndex, endCordinationsIndex - startCordinationsIndex);
- Console.WriteLine($"Found {treasureType} at {treasureCordinates}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement