Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- namespace Problem03
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> journal = Console.ReadLine().Split(", ").ToList();
- string input = Console.ReadLine(); // Drop - Wood
- while ("Craft!" != input)
- {
- string[] tokens = input.Split(" - ");
- string command = tokens[0];
- string item = tokens[1];
- if ("Collect" == command)
- {
- if (!journal.Contains(item))
- {
- journal.Add(item);
- }
- }
- else if ("Drop" == command)
- {
- journal.Remove(item);
- }
- else if ("Combine Items" == command)
- {
- string[] items = item.Split(":");
- string oldItem = items[0];
- string newItem = items[1];
- int index = journal.IndexOf(oldItem);
- if (index >= 0)
- {
- journal.Insert(index + 1, newItem);
- }
- }
- else if ("Renew" == command)
- {
- int index = journal.IndexOf(item);
- if (index >= 0)
- {
- string element = journal[index];
- journal.Remove(element);
- journal.Add(element);
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine(string.Join(", ", journal));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment