Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Linq;
- namespace TreasureFinder
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
- string text = string.Empty;
- string type = string.Empty;
- string coordinates = string.Empty;
- while((text=Console.ReadLine())!="find")
- {
- int maxLength = Math.Max(numbers.Length, text.Length);// found maxLength
- StringBuilder sb = new StringBuilder(maxLength);
- for (int i = 0; i < maxLength; i++)
- {
- sb.Append((char)(text[i] - numbers[i % numbers.Length]));// NB! how to looping
- }
- int startIndexType = sb.ToString().IndexOf('&') + 1;
- int endIndexType = sb.ToString().IndexOf('&', startIndexType + 1);
- int typeLength = endIndexType - startIndexType;
- type = sb.ToString().Substring(startIndexType, typeLength);
- int startIndexCoordinates = sb.ToString().IndexOf('<') + 1;
- int endIndexCoordinates = sb.ToString().IndexOf('>');
- int coordinatesLength = endIndexCoordinates - startIndexCoordinates;
- coordinates = sb.ToString().Substring(startIndexCoordinates, coordinatesLength);
- Console.WriteLine($"Found {type} at {coordinates}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement