Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace TakeSkipRope
- {
- class Program
- {
- static void Main(string[] args)
- {
- string message = Console.ReadLine();
- List<char> numberList = message.Where(x => x >= '0' && x <= '9').ToList();
- List<char> nonNumberList = message.Where(x => x < '0' || x > '9').ToList();
- int modificationIndex = 0;
- for (int i = 0; i < numberList.Count; i += 2)
- {
- modificationIndex += numberList[i] - 48;
- int finalIndex = modificationIndex + numberList[i + 1] - 48;
- finalIndex = finalIndex >= nonNumberList.Count ? nonNumberList.Count : finalIndex;
- for (int j = modificationIndex; j < finalIndex; j++)
- {
- nonNumberList.RemoveAt(modificationIndex);
- }
- }
- while (modificationIndex < nonNumberList.Count)
- {
- nonNumberList.RemoveAt(modificationIndex);
- }
- Console.WriteLine(string.Join("", nonNumberList));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement