02. Easter Gifts- Technology Fundamentals Retake Mid Exam - 16 April 2019 (maybe Judge problem)
Please, can somebody try to submit for this exercise https://judge.softuni.bg/Contests/Practice/Index/1610#1 ? I think maybe their is a problem in Judge System, because I can't to submit my solution. Only showed this message "The contest cannot be practiced!". On my computer there is no problem, everything is ok.
You can check with my code:
using System;
using System.Collections.Generic;
using System.Linq;
namespace midExamFinal
{
class MainClass
{
public static void Main(string[] args)
{
List<string> listOfGifts = Console.ReadLine().Split().ToList();
string command = string.Empty;
while ((command = Console.ReadLine()) != "No Money")
{
string[] commandArray = command.Split();
if (commandArray[0] == "OutOfStock")
{
string gift = commandArray[1];
while (listOfGifts.Exists(x => x == gift))
{
int indexOfGift = listOfGifts.IndexOf(gift);
listOfGifts[indexOfGift] = "None";
}
}
else if (commandArray[0] == "Required")
{
string gift = commandArray[1];
int index = int.Parse(commandArray[2]);
if (index >= 0 && index <= listOfGifts.Count - 1)
{
listOfGifts[index] = gift;
}
}
else if (commandArray[0] == "JustInCase")
{
string gift = commandArray[1];
listOfGifts[listOfGifts.Count - 1] = gift;
}
}
var result = listOfGifts.Where(x => x != "None");
Console.WriteLine(string.Join(" ",result));
}
}
}