Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace String_Explosion
- {
- class Program
- {
- static void Main()
- {
- string[] input = Console.ReadLine()
- .Split('>')
- .ToArray();
- int finalCountRemove = 0;
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i][0] >= '0' && input[i][0] <= '9')
- {
- int killCount = (int)input[i][0] - 48;
- finalCountRemove += killCount;
- if (finalCountRemove >= input[i].Length)
- {
- finalCountRemove -= input[i].Length;
- input[i] = input[i].Remove(0, input[i].Length);
- }
- else
- {
- input[i] = input[i].Remove(0, finalCountRemove);
- finalCountRemove = 0;
- }
- }
- }
- Console.WriteLine(string.Join('>', input));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement