Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace ConsoleApp21
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> parts = Console.ReadLine().Split("|").ToList();
- string command;
- while ((command = Console.ReadLine()) != "Done")
- {
- string[] split = command.Split();
- if (command.Contains("Move Left"))
- {
- int index = int.Parse(split[2]);
- int res = index -1;
- if (index> 0 && index < parts.Count)
- {
- string word = parts[index];
- parts.RemoveAt(index);
- parts.Insert(res, word);
- }
- }
- else if (command.Contains("Move Right"))
- {
- int index = int.Parse(split[2]);
- int res = index + 1;
- if (index >= 0 && index < parts.Count-1)
- {
- string word = parts[index];
- parts.RemoveAt(index);
- parts.Insert(res, word);
- }
- }
- if (command.Contains("Check Even"))
- {
- for (int i = 0; i < parts.Count; i++)
- {
- if (i%2==0)
- {
- Console.Write($"{parts[i]} ");
- }
- }
- Console.WriteLine();
- }
- if (command.Contains("Check Odd"))
- {
- for (int i = 0; i < parts.Count; i++)
- {
- if (i % 2 == 1)
- {
- Console.Write($"{parts[i]} ");
- }
- }
- Console.WriteLine();
- }
- }
- Console.WriteLine($"You crafted {string.Join("",parts)}! ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement