Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace _07_Hideout
- {
- public class Hideout
- {
- public static void Main()
- {
- string map = Console.ReadLine();
- while (true)
- {
- string line = Console.ReadLine();
- var tokens = line.Split().ToArray();
- var searchedChar = Regex.Escape(tokens[0]);
- var minCount = int.Parse(tokens[1]);
- var regex = new Regex($@"{searchedChar}{{{minCount},}}");
- var match = regex.Match(map);
- if (match.Success)
- {
- var index = match.Groups[0].Index;
- var count = match.Groups[0].Value.Length;
- Console.WriteLine($"Hideout found at index {index} and it is with size {count}!");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement