Advertisement
Guest User

Hideout

a guest
Nov 1st, 2017
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. namespace Hideout
  2. {
  3.     using System;
  4.     using System.Linq;
  5.     using System.Text.RegularExpressions;
  6.  
  7.     public class StartUp
  8.     {
  9.         public static void Main()
  10.         {
  11.             string map = Console.ReadLine();
  12.  
  13.             while (true)
  14.             {
  15.                 string[] clues = Console.ReadLine()
  16.                                 .Trim()
  17.                                 .Split(new string[] { " " }, StringSplitOptions
  18.                                 .RemoveEmptyEntries)
  19.                                 .ToArray();
  20.  
  21.                 string hideout = clues[0];
  22.                 int minSize = int.Parse(clues[1]);
  23.  
  24.                 string pattern = $@"[{hideout}]+";
  25.  
  26.                 foreach (Match item in Regex.Matches(map, pattern))
  27.                 {
  28.                     if (item.Length >= minSize)
  29.                     {
  30.                         Console.WriteLine($"Hideout found at index {item.Index} and it is with size {item.Length}!");
  31.  
  32.                         return;
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement