diff --git a/logic/handler.js b/logic/handler.js index 17ca28a..f245bcb 100644 --- a/logic/handler.js +++ b/logic/handler.js @@ -17,6 +17,8 @@ function getQuestionPlaceHolder(questionsData, currentLanguage, questionIndex, s return question.placeHolderCpp; } else if (currentLanguage === "Go") { return question.placeHolderGo; + } else if (currentLanguage === "Python") { + return question.placeHolderPython } } else { return "No questions available for the selected categories"; @@ -56,6 +58,8 @@ function getAnswer(questionsData, currentLanguage, questionIndex) { return questionsData[questionIndex].answerCpp } else if (currentLanguage === "Go") { return questionsData[questionIndex].answerGo + } else if (currentLanguage === "Python") { + return questionsData[questionIndex].answerPython } } else { return "" diff --git a/logic/intervals/insert-interval.js b/logic/intervals/insert-interval.js index 5e8c9f7..78387e8 100644 --- a/logic/intervals/insert-interval.js +++ b/logic/intervals/insert-interval.js @@ -4,6 +4,7 @@ var question = [ category: "Intervals", placeHolderCpp: `vector insertInterval(vector& intervals, Interval newInterval) {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`, placeHolderGo: `func insertInterval(intervals []Interval, newInterval Interval) []Interval {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`, + placeHolderPython: `def insert_interval(intervals, new_interval):\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`, spaceComplexity: "O(N)", timeComplexity: "O(N)", difficulty: "Medium", @@ -70,6 +71,33 @@ func max(a, b int) int { return a } return b -}` +}`, + answerPython: `class Interval: +def __init__(self, start, end): + self.start = start + self.end = end + +def insert_interval(intervals, new_interval): + result = [] + i = 0 + n = len(intervals) + + while i < n and intervals[i].end < new_interval.start: + result.append(intervals[i]) + i += 1 + + while i < n and intervals[i].start <= new_interval.end: + new_interval.start = min(new_interval.start, intervals[i].start) + new_interval.end = max(new_interval.end, intervals[i].end) + i += 1 + + result.append(new_interval) # Add the merged interval + + while i < n: + result.append(intervals[i]) + i += 1 + + return result +` } ] diff --git a/logic/template.js b/logic/template.js index f20cacc..f261fb3 100644 --- a/logic/template.js +++ b/logic/template.js @@ -4,10 +4,12 @@ var question = [ category: "", placeHolderCpp: `{\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`, placeHolderGo: `{\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`, + placeHolderPython: `{\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`, difficulty: "", question: "", answerImage: "", answerCpp: ``, - answerGo: `` + answerGo: ``, + answerPython: `` } ] diff --git a/qml/PracticePage.qml b/qml/PracticePage.qml index d8caeef..ecfd519 100644 --- a/qml/PracticePage.qml +++ b/qml/PracticePage.qml @@ -455,7 +455,7 @@ Rectangle { ComboBox { id: languageComboBox - model: [ "C++", "Go" ] + model: [ "C++", "Go", "Python" ] currentIndex: 0 visible: !quizComplete Layout.alignment: Qt.AlignRight diff --git a/sessionData.json b/sessionData.json new file mode 100644 index 0000000..e69de29