Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _01.Regeh
- {
- public class Startup
- {
- public static void Main()
- {
- var input = Console.ReadLine();
- var pattern = new Regex(@"\[\w+<(\d+)REGEH(\d+)>\w+]");
- var matches = pattern.Matches(input);
- var index = 0;
- var result = string.Empty;
- foreach (Match match in matches)
- {
- index += int.Parse(match.Groups[1].ToString());
- if (index > input.Length - 1)
- {
- index = (index % input.Length) + 1;
- }
- result += input[index];
- index += int.Parse(match.Groups[2].ToString());
- if (index > input.Length - 1)
- {
- index = (index % input.Length) + 1;
- }
- result += input[index];
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement