10. *SoftUni Course Planning от Exercise: Lists
Моето решение: https://pastebin.com/uEDj39MA
След много проверки, корекции и т.н. получавам 88/100 /един грешен тест/.
Помощ при откраване на грешката?
Предварително благодаря!
Моето решение: https://pastebin.com/uEDj39MA
След много проверки, корекции и т.н. получавам 88/100 /един грешен тест/.
Помощ при откраване на грешката?
Предварително благодаря!
Had the same problem with my solution, Test #8 error is triggered by the 'Exercise' operation which requires to check whether a given course AND it's exercise exist or not or just one of the two.
Exercise-operation (88%):
static List<string> ExerciseOperator(string title, List<string> courseSchedule)
{
bool courseExist = courseSchedule.Exists(course => course == title);
int courseIndex = courseSchedule.FindIndex(course => course == title);
int exerciseIndex = courseIndex + 1;
if (courseExist)
{
courseSchedule.Insert(exerciseIndex, title + "-Exercise");
}
else if (courseExist == false)
{
courseSchedule.Add(title);
courseSchedule.Add(title + "-Exercise");
}
return courseSchedule;
}
Exercise-operation (100%):
static List<string> ExerciseOperator(string title, List<string> courseSchedule)
{
bool courseExist = courseSchedule.Exists(course => course == title);
bool exerciseExist = courseSchedule.Exists(course => course == title + "-Exercise");
int courseIndex = courseSchedule.FindIndex(course => course == title);
int exerciseIndex = courseIndex + 1;
if (courseExist && exerciseExist == false)
{
courseSchedule.Insert(exerciseIndex, title + "-Exercise");
}
else if (courseExist == false)
{
courseSchedule.Add(title);
courseSchedule.Add(title + "-Exercise");
}
return courseSchedule;
}
Best,