Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TakeSkip_Rope
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var encryptedMessage = Console.ReadLine();
  14. var numberList = new List<int>();
  15. var charList = new List<char>();
  16.  
  17. foreach (var symbol in encryptedMessage)
  18. {
  19. if (char.IsDigit(symbol))
  20. {
  21. int num = int.Parse(symbol.ToString());
  22. numberList.Add(num);
  23. }
  24. else
  25. {
  26. charList.Add(symbol);
  27. }
  28. }
  29. var takeList = new List<int>();
  30. var skipList = new List<int>();
  31.  
  32. for (int index = 0; index < numberList.Count; index++)
  33. {
  34. if (index % 2 == 0)
  35. {
  36. takeList.Add(numberList[index]);
  37. }
  38. else
  39. {
  40. skipList.Add(numberList[index]);
  41. }
  42. }
  43.  
  44. string result = null;
  45.  
  46. var total = 0;
  47. for (int index = 0; index < skipList.Count; index++)
  48. {
  49. int skipCount = skipList[index];
  50. int takeCoun = takeList[index];
  51. result += new string(charList.Skip(total).Take(takeCoun).ToArray());
  52. total += skipCount + takeCoun;
  53. }
  54. Console.WriteLine(result);
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement