Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace test
- {
- internal class Program
- {
- private static void Main(string[] args)
- {
- Console.WriteLine("Enter the length of the marble sequence");
- int length = int.Parse(Console.ReadLine());
- string[] marbles = new string[length];
- for (int i = 0; i < length; i++)
- {
- marbles[i] = Console.ReadLine();
- }
- bool sequence = true;
- while (sequence)
- {
- sequence = false;
- for (int i = 0; i < marbles.Length; i++)
- {
- for (int j = 0; j < marbles[i].Length - 2; j++)
- {
- if (marbles[i][j] != marbles[i][j + 1] || marbles[i][j] != marbles[i][j + 2])
- {
- continue;
- }
- marbles[i] = marbles[i].Substring(0, j) + marbles[i].Substring(j + 3, marbles[i].Length - j - 3);
- sequence = true;
- break;
- }
- }
- }
- for (int i = 0; i < marbles.Length; i++)
- {
- Console.WriteLine(marbles[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement