Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. public class Program
  8. {
  9.     public static void Main()
  10.     {
  11.         List<string> quests = Console.ReadLine().Split(new string[] {", "}, StringSplitOptions.RemoveEmptyEntries).ToList();
  12.  
  13.         string command = Console.ReadLine();
  14.  
  15.         while (command != "Retire!")
  16.         {
  17.             List<string> tokens = command.Split(new string[]{" - "},StringSplitOptions.RemoveEmptyEntries).ToList();
  18.  
  19.             if (tokens[0] == "Start")
  20.             {
  21.                 string quest = tokens[1];
  22.                 if (!quests.Contains(quest))
  23.                 {
  24.                     quests.Add(quest);
  25.                 }
  26.             }else if (tokens[0] == "Complete")
  27.             {
  28.                 string quest = tokens[1];
  29.                 if (quests.Contains(quest))
  30.                 {
  31.                     quests.Remove(quest);
  32.                 }
  33.  
  34.             }else if (tokens[0] == "Side Quest")
  35.             {
  36.                 string questPair = tokens[1];
  37.                 List<string> questAndSideQuest = questPair.Split(':').ToList();
  38.  
  39.                 if (quests.Contains(questAndSideQuest[0]) && !quests.Contains(questAndSideQuest[1]))
  40.                 {
  41.                     int index = quests.FindIndex(x => x == questAndSideQuest[0]);
  42.                     quests.Insert(index + 1, questAndSideQuest[1]);
  43.                 }
  44.  
  45.             }else if (tokens[0] == "Renew")
  46.             {
  47.                 string quest = tokens[1];
  48.  
  49.                 if (quests.Contains(quest))
  50.                 {
  51.                     quests.Remove(quest);
  52.                     quests.Add(quest);
  53.                 }
  54.             }
  55.             command = Console.ReadLine();
  56.         }
  57.  
  58.         Console.WriteLine(string.Join(", ",quests));
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement