Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- namespace Black_Flag
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine()
- .Split('|').Where(s => !string.IsNullOrWhiteSpace(s))
- .ToList();
- string commandLine;
- while ((commandLine = Console.ReadLine()) != "Done")
- {
- if (commandLine.Split(" ")[0] == "Move")
- {
- var splitCommands = commandLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string command = splitCommands[1];
- int index = int.Parse(splitCommands[2]);
- if (command == "Left")
- {
- if (index - 1 >= 0)
- {
- var value = input[index];
- input.RemoveAt(index);
- input.Insert(index - 1, value);
- }
- }
- else
- {
- if (index + 1 < input.Count)
- {
- var value = input[index];
- input.RemoveAt(index);
- input.Insert(index + 1, value);
- }
- }
- }
- else
- {
- int index = int.Parse(commandLine.Split(" ")[1]);
- if (index >= 0 && index < input.Count)
- {
- input.RemoveAt(index);
- }
- }
- }
- Console.WriteLine($"You crafted {string.Join("", input)}!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement