Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _07._String_Explosion
- {
- class Program
- {
- static void Main(string[] args)
- {
- string field = Console.ReadLine();
- List<char> elementsOfField = new List<char>();
- int explosionRadius = 0;
- for (int i = 0; i < field.Length; i++)
- {
- elementsOfField.Add(field[i]);
- }
- for (int j = 0; j < elementsOfField.Count; j++)
- {
- if (elementsOfField[j] == '>')
- {
- double radius = char.GetNumericValue(elementsOfField[j + 1]);
- for (int k = j; k < elementsOfField[(int)(radius + explosionRadius)]; k++)
- {
- j++;
- explosionRadius = 0;
- if (elementsOfField[k + 1] != '>')
- {
- elementsOfField.RemoveAt(k + 1);
- if (explosionRadius > 0)
- {
- explosionRadius--;
- }
- }
- else
- {
- explosionRadius++;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement