Advertisement
Guest User

Untitled

a guest
Feb 6th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. namespace _04.Regeh
  6. {
  7. class Regeh
  8. {
  9. static void Main(string[] args)
  10. {
  11. var input = Console.ReadLine();
  12. var pattern = @"\[[A-Z&a-z]+<([0-9]+)REGEH([0-9]+)>[A-Z&a-z]+\]";
  13. var regex = Regex.Matches(input, pattern);
  14. var num = new List<int>();
  15. string result = string.Empty;
  16.  
  17. foreach (Match match in regex)
  18. {
  19. num.Add(int.Parse(match.Groups[1].Value));
  20. num.Add(int.Parse(match.Groups[2].Value));
  21. }
  22. int numLenght = num.Count;
  23. result += input[num[0]];
  24. int numSum = num[0];
  25. var inputLen = input.Length;
  26. for (int i = 1; i < numLenght; i++)
  27. {
  28. numSum += num[i];
  29. if (numSum >= input.Length)
  30. {
  31.  
  32. result += input[(numSum % input.Length)+1];
  33. }
  34. else
  35. {
  36.  
  37. result += input[numSum % input.Length];
  38. }
  39.  
  40.  
  41. }
  42.  
  43. Console.WriteLine(result);
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement