Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- StringBuilder message = new StringBuilder(Console.ReadLine());
- string input;
- while ((input = Console.ReadLine()) != "Decode")
- {
- string[] tokens = input.Split('|');
- switch (tokens[0])
- {
- case "Move":
- int length = int.Parse(tokens[1]);
- string substring = string.Join("", message.ToString().Take(length));
- message.Remove(0, length);
- message.Append(substring);
- break;
- case "Insert":
- int index = int.Parse(tokens[1]);
- string chunk = tokens[2];
- if (index == message.Length)
- message.Append(chunk);
- else
- message.Insert(index, chunk);
- break;
- case "ChangeAll":
- string toReplace = tokens[1];
- string replacement = tokens[2];
- message.Replace(toReplace, replacement);
- break;
- }
- }
- Console.WriteLine($"The decrypted message is: {message}");
- }
- }
Add Comment
Please, Sign In to add comment