Advertisement
Rayk

Untitled

Nov 1st, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace _07_Hideout
  6. {
  7. public class Hideout
  8. {
  9. public static void Main()
  10. {
  11. string map = Console.ReadLine();
  12.  
  13. while (true)
  14. {
  15. string line = Console.ReadLine();
  16.  
  17. var tokens = line.Split().ToArray();
  18. var searchedChar = Regex.Escape(tokens[0]);
  19. var minCount = int.Parse(tokens[1]);
  20.  
  21. var regex = new Regex($@"{searchedChar}{{{minCount},}}");
  22. var match = regex.Match(map);
  23.  
  24. if (match.Success)
  25. {
  26. var index = match.Groups[0].Index;
  27. var count = match.Groups[0].Value.Length;
  28. Console.WriteLine($"Hideout found at index {index} and it is with size {count}!");
  29. break;
  30. }
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement