Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _02Santa_sList
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> noisyKids = Console.ReadLine().Split('&').ToList();
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "Finished!")
- {
- break;
- }
- string[] tokens = command.Split();
- string action = tokens[0];
- if (action=="Bad")
- {
- string kidName = tokens[1];
- if (noisyKids.Contains(kidName)==false)
- {
- noisyKids.Insert(0, kidName);
- }
- }
- else if (action=="Good")
- {
- string kidName = tokens[1];
- if (noisyKids.Contains(kidName))
- {
- noisyKids.Remove(kidName);
- }
- }
- else if (action == "Rename")
- {
- string oldName = tokens[1];
- string newName = tokens[2];
- if (noisyKids.Contains(oldName))
- {
- int index = noisyKids.IndexOf(oldName);
- noisyKids.Insert(index, newName);
- noisyKids.Remove(oldName);
- }
- }
- else if (action == "Rearrange")
- {
- string kidName = tokens[1];
- if (noisyKids.Contains(kidName))
- {
- noisyKids.Remove(kidName);
- noisyKids.Add(kidName);
- }
- }
- }
- Console.WriteLine(string.Join(", ",noisyKids));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement