WindFell

Camera View

May 22nd, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. class CameraView
  7. {
  8.     static void Main(string[] args)
  9.     {
  10.         int[] tokens = Console.ReadLine()
  11.             .Split()
  12.             .Select(int.Parse)
  13.             .ToArray();
  14.  
  15.         int skipCount = tokens[0];
  16.         int takeCount = tokens[1];
  17.         string input = Console.ReadLine();
  18.  
  19.         List<string> cameras = new List<string>();
  20.         string pattern = @"\|<(\w{" + skipCount + @"})(?<camera>\w{1," + takeCount + @"})";
  21.         MatchCollection matches = Regex.Matches(input, pattern);
  22.  
  23.         foreach (Match camera in matches)
  24.         {
  25.             cameras.Add(camera.Groups["camera"].Value);
  26.         }
  27.  
  28.         Console.WriteLine(string.Join(", ", cameras));
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment