Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace TheImitationGame
- {
- class Program
- {
- static void Main(string[] args)
- {
- string message = Console.ReadLine();
- string input;
- while ((input = Console.ReadLine()) != "Decode")
- {
- var tokens = input.Split('|');
- string command = tokens[0];
- if (command == "Move")
- {
- int index = int.Parse(tokens[1]);
- string subStr = message.Substring(0, index);
- message = message.Replace(subStr, "") + subStr;
- }
- else if (command == "Insert")
- {
- int index = int.Parse(tokens[1]);
- string value = tokens[2];
- message = message.Insert(index, value);
- }
- else if (command == "ChangeAll")
- {
- string oldStr = tokens[1];
- string newStr = tokens[2];
- message = message.Replace(oldStr, newStr);
- }
- }
- Console.WriteLine($"The decrypted message is: {message}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement