Skip to content

Commit f7320a3

Browse files
committed
feat : added daily dsa in bubble sort
1 parent 04c04f7 commit f7320a3

5 files changed

Lines changed: 38 additions & 52 deletions

File tree

app/visualizer/searching/binarysearch/page.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ export default function Page() {
8686
<Content />
8787
</section>
8888

89-
<section>
89+
<section className="px-6">
9090
<Animation />
9191
</section>
9292

93-
<section>
93+
<section className="px-6">
9494
<p className="text-lg text-center text-gray-600 dark:text-gray-400 mb-8">
9595
Test Your Knowledge before moving forward!
9696
</p>
9797
<Quiz />
9898
</section>
9999

100-
<section>
100+
<section className="px-6">
101101
<CodeBlock />
102102
</section>
103103

@@ -110,7 +110,7 @@ export default function Page() {
110110
/>
111111
</section>
112112

113-
<section>
113+
<section className="px-6">
114114
<ExploreOther
115115
title="Explore other operations"
116116
links={[{ text: "Linear Search", url: "./linearsearch" }]}

app/visualizer/searching/linearsearch/page.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ export default function Page() {
8686
<Content />
8787
</section>
8888

89-
<section>
89+
<section className="px-6">
9090
<LinearSearchAnimation />
9191
</section>
9292

93-
<section>
93+
<section className="px-6">
9494
<p className="text-lg text-center text-gray-600 dark:text-gray-400 mb-2">
9595
Test Your Knowledge before moving forward!
9696
</p>
9797
<Quiz />
9898
</section>
9999

100-
<section>
100+
<section className="px-6">
101101
<Code />
102102
</section>
103103

@@ -110,7 +110,7 @@ export default function Page() {
110110
/>
111111
</section>
112112

113-
<section>
113+
<section className="px-6">
114114
<ExploreOther
115115
title="Explore other operations"
116116
links={[{ text: "Binary Search", url: "./binarysearch" }]}

app/visualizer/sorting/bubblesort/content.jsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,30 @@ const content = () => {
5757
];
5858

5959
return (
60-
<main className="max-w-4xl mx-auto">
61-
<article className="bg-white dark:bg-neutral-950 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
60+
<main className="max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-5 md:gap-4">
61+
<div className="col-span-1">
62+
<div className="hidden md:block">
63+
<iframe
64+
src="https://hw.glich.co/resources/embed/daily/dsa"
65+
width="100%"
66+
height="400"
67+
title="Daily DSA Challenge"
68+
></iframe>
69+
</div>
70+
<div className="flex justify-center">
71+
<span className="text-xs hidden md:block">
72+
Powered by{" "}
73+
<a
74+
href="https://hw.glich.co/resources/daily"
75+
target="_blank"
76+
className="underline hover:text-blue-500 duration-300"
77+
>
78+
Hello World
79+
</a>
80+
</span>
81+
</div>
82+
</div>
83+
<article className="col-span-4 max-w-4xl bg-white dark:bg-neutral-950 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-8">
6284
{/* What is Bubble Sort */}
6385
<section className="p-6 border-b border-gray-100 dark:border-gray-700">
6486
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4 flex items-center">
@@ -205,4 +227,4 @@ const content = () => {
205227
);
206228
};
207229

208-
export default content;
230+
export default content;

app/visualizer/sorting/bubblesort/page.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function Page() {
6464

6565
<div className="py-20 bg-gray-100 dark:bg-neutral-900 text-gray-800 dark:text-gray-200">
6666
<section className="px-6 md:px-12">
67-
<div className="mt-10 sm:mt-10">
67+
<div className="mt-10 sm:mt-10 mb-4">
6868
<Breadcrumbs paths={paths} />
6969
</div>
7070
<div className="flex items-center flex-col">
@@ -86,14 +86,14 @@ export default function Page() {
8686
<Animation />
8787
</section>
8888

89-
<section>
89+
<section className="px-6">
9090
<p className="text-lg text-center text-gray-600 dark:text-gray-400 mb-2">
9191
Test Your Knowledge before moving forward!
9292
</p>
9393
<Quiz />
9494
</section>
9595

96-
<section>
96+
<section className="px-6">
9797
<Code />
9898
</section>
9999

@@ -106,7 +106,7 @@ export default function Page() {
106106
/>
107107
</section>
108108

109-
<section>
109+
<section className="px-6">
110110
<ExploreOther
111111
title="Explore Sorting Algorithms"
112112
links={[

app/visualizer/sorting/bubblesort/quiz.jsx

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,10 @@ const BubbleSortQuiz = () => {
9595
const [showResult, setShowResult] = useState(false);
9696
const [quizCompleted, setQuizCompleted] = useState(false);
9797
const [answers, setAnswers] = useState(Array(questions.length).fill(null));
98-
const [showExplanation, setShowExplanation] = useState(false);
9998
const [showIntro, setShowIntro] = useState(true);
10099
const [showSuccessAnimation, setShowSuccessAnimation] = useState(false);
101-
const [penaltyApplied, setPenaltyApplied] = useState(false);
102100

103101
const handleAnswerSelect = (optionIndex) => {
104-
if (selectedAnswer !== null) return;
105102
setSelectedAnswer(optionIndex);
106103
const newAnswers = [...answers];
107104
newAnswers[currentQuestion] = optionIndex;
@@ -111,18 +108,10 @@ const BubbleSortQuiz = () => {
111108
const handleNextQuestion = () => {
112109
if (selectedAnswer === null) return;
113110

114-
if (showExplanation && !penaltyApplied) {
115-
setScore((prevScore) => Math.max(0, prevScore - 0.5));
116-
setPenaltyApplied(true);
117-
}
118-
119111
if (selectedAnswer === questions[currentQuestion].correctAnswer) {
120112
setScore(score + 1);
121113
}
122114

123-
setShowExplanation(false);
124-
setPenaltyApplied(false);
125-
126115
if (currentQuestion < questions.length - 1) {
127116
setCurrentQuestion(currentQuestion + 1);
128117
setSelectedAnswer(null);
@@ -137,7 +126,6 @@ const BubbleSortQuiz = () => {
137126
};
138127

139128
const handlePreviousQuestion = () => {
140-
setShowExplanation(false);
141129
setCurrentQuestion(currentQuestion - 1);
142130
setSelectedAnswer(answers[currentQuestion - 1]);
143131
};
@@ -149,9 +137,7 @@ const BubbleSortQuiz = () => {
149137
setShowResult(false);
150138
setQuizCompleted(false);
151139
setAnswers(Array(questions.length).fill(null));
152-
setShowExplanation(false);
153140
setShowIntro(true);
154-
setPenaltyApplied(false);
155141
};
156142

157143
const calculateWeakAreas = () => {
@@ -332,29 +318,7 @@ const BubbleSortQuiz = () => {
332318
))}
333319
</div>
334320

335-
{selectedAnswer !== null && (
336-
<div className="mb-6">
337-
<button
338-
onClick={() => setShowExplanation(!showExplanation)}
339-
className="text-sm flex items-center text-blue-600 dark:text-blue-400 hover:underline mb-2"
340-
>
341-
<FaInfoCircle className="mr-1" />
342-
{showExplanation ? "Hide Explanation" : "Show Explanation"}
343-
</button>
344-
<AnimatePresence>
345-
{showExplanation && (
346-
<motion.div
347-
initial={{ opacity: 0, height: 0 }}
348-
animate={{ opacity: 1, height: "auto" }}
349-
exit={{ opacity: 0, height: 0 }}
350-
className="p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg text-sm overflow-hidden"
351-
>
352-
{questions[currentQuestion].explanation}
353-
</motion.div>
354-
)}
355-
</AnimatePresence>
356-
</div>
357-
)}
321+
358322
</motion.div>
359323

360324
<div className="flex justify-between">

0 commit comments

Comments
 (0)