Advertisement
YavorGrancharov

Stateless(text_process)

Aug 5th, 2017
101
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. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Stateless
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string state = Console.ReadLine();
  14.  
  15.             while (state != "collapse")
  16.             {
  17.                 string fiction = Console.ReadLine();
  18.  
  19.                 while (fiction.Length > 0)
  20.                 {
  21.                     if (state.Contains(fiction))
  22.                     {
  23.                         state = state.Replace(fiction, "");
  24.                     }
  25.                     else
  26.                     {
  27.                         fiction = fiction.Remove(0, 1);
  28.  
  29.                         if (fiction.Length > 0)
  30.                         {
  31.                             fiction = fiction.Remove((fiction.Length - 1), 1);
  32.                         }
  33.                     }            
  34.                 }
  35.                
  36.                 if (state.Length > 0)
  37.                 {
  38.                     Console.WriteLine(state);
  39.                 }
  40.                 else
  41.                 {
  42.                     Console.WriteLine("(void)");
  43.                 }              
  44.                 state = Console.ReadLine();
  45.             }          
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement