SoftUni Course Planning
Здравейте, може ли малко помощ по тази задача - решавам я на 77/100 и не мога да разбера къде греша .
https://judge.softuni.bg/Contests/Compete/Index/1211#9
Код :https://pastebin.com/wA8g2DMz
Благодаря предварително!
Здравейте, може ли малко помощ по тази задача - решавам я на 77/100 и не мога да разбера къде греша .
https://judge.softuni.bg/Contests/Compete/Index/1211#9
Код :https://pastebin.com/wA8g2DMz
Благодаря предварително!
Seems to be OK, the only thing that needs to be completed is the REMOVE function, which also needs to delete the corresponding exercise of a given lesson:
"Each time you Swap or Remove a lesson, you should do the same with the Exercises, if there are any, which follow the lessons."
Remove:
else if (firstCommand == "Remove")
{
lessons.Remove(lessonTitle);
lessons.Remove(lessonTitle + "-Exercise");
}
Maybe check also your SWAP method with other solutions from the forum, just in case that some other judge-errors come up.
Swap-Demo:
static List<string> SwapOperator(string title1, string title2, List<string> courseSchedule)
{
bool course1Exist = courseSchedule.Exists(course => course == title1);
bool course2Exist = courseSchedule.Exists(course => course == title2);
bool exercise1Exist = courseSchedule.Exists(course => course == title1 + "-Exercise");
bool exercise2Exist = courseSchedule.Exists(course => course == title2 + "-Exercise");
int course1Index = courseSchedule.FindIndex(course => course == title1);
int course2Index = courseSchedule.FindIndex(course => course == title2);
int exercise1Index = courseSchedule.FindIndex(course => course == title1 + "-Exercise");
int exercise2Index = courseSchedule.FindIndex(course => course == title2 + "-Exercise");
if (course1Exist && course2Exist)
{
string oldElement = courseSchedule[course1Index];
courseSchedule[course1Index] = courseSchedule[course2Index];
courseSchedule[course2Index] = oldElement;
course1Index = courseSchedule.FindIndex(course => course == title1);
course2Index = courseSchedule.FindIndex(course => course == title2);
if (exercise1Exist && exercise2Exist)
{
string oldElement2 = courseSchedule[exercise1Index];
courseSchedule[exercise1Index] = courseSchedule[exercise2Index];
courseSchedule[exercise2Index] = oldElement2;
}
else if (exercise1Exist)
{
string oldElement4 = courseSchedule[exercise1Index];
courseSchedule.Remove(oldElement4);
courseSchedule.Insert(course1Index + 1, oldElement4);
}
else if (exercise2Exist)
{
string oldElement5 = courseSchedule[exercise2Index];
courseSchedule.Remove(oldElement5);
courseSchedule.Insert(course2Index + 1, oldElement5);
}
}
return courseSchedule;
}
Best,
Thanks a lot !