Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

nadejda91iv avatar nadejda91iv 11 Точки

SoftUni Course Planning

Здравейте, може ли малко помощ по тази задача - решавам я на 77/100 и не мога да разбера къде греша .

https://judge.softuni.bg/Contests/Compete/Index/1211#9

Код :https://pastebin.com/wA8g2DMz

Благодаря предварително!

Тагове:
0
Programming Fundamentals
Axiomatik avatar Axiomatik 2422 Точки
Best Answer

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,

0
nadejda91iv avatar nadejda91iv 11 Точки

Thanks a lot !

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.