Guest User

Untitled

a guest
Aug 30th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2.     using System.Collections.Generic;
  3.     using System.Linq;
  4.  
  5.     public class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.             string lineOne = Console.ReadLine();
  10.  
  11.             while (lineOne != "collapse")
  12.             {
  13.                 string lineTwo = Console.ReadLine();
  14.  
  15.                 while (lineTwo.Length > 0)
  16.                 {
  17.                     bool contains = lineOne.Contains(lineTwo);
  18.  
  19.                     if (contains)
  20.                     {
  21.                         lineOne = lineOne.Replace(lineTwo, string.Empty);
  22.                         contains = false;
  23.                     }
  24.                     else
  25.                     {
  26.                         lineTwo = lineTwo.Remove(0, 1);
  27.                         if (lineTwo.Length > 0)
  28.                         {
  29.                             lineTwo = lineTwo.Remove((lineTwo.Length - 1), 1);
  30.                         }
  31.                     }
  32.                 }
  33.  
  34.                 if (lineOne.Length > 0)
  35.                 {
  36.                     Console.WriteLine(lineOne.Trim());
  37.                 }
  38.                 else
  39.                 {
  40.                     Console.WriteLine("(void)");
  41.                 }
  42.  
  43.                 lineOne = Console.ReadLine();
  44.             }
  45.         }
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment