Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- namespace _01.Imitation_Game
- {
- class Program
- {
- static void Main(string[] args)
- {
- string encryptedMessage = Console.ReadLine();
- string instructions = Console.ReadLine();
- string message = encryptedMessage;
- while (instructions != "Decode")
- {
- string[] cmd = instructions.Split('|').ToArray();
- var cmd1 = cmd[0];
- var cmd2 = cmd[1];
- if (cmd1 == "Move")
- {
- string substr = message.Substring(0, int.Parse(cmd2));
- string editedMessage = message.Insert(message.Length, substr).Remove(0, int.Parse(cmd2));
- message = editedMessage;
- }
- if (cmd1 == "Insert")
- {
- var cmd3 = cmd[2];
- string editedMessage = message.Insert(int.Parse(cmd2), cmd3);
- message = editedMessage;
- }
- if (cmd1 == "ChangeAll")
- {
- var cmd3 = cmd[2];
- string editedMessage = message.Replace(cmd2, cmd3);
- message = editedMessage;
- }
- instructions = Console.ReadLine();
- }
- Console.WriteLine($"The decrypted message is: {message}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement