ROSS09 commited on
Commit
4840ed8
·
verified ·
1 Parent(s): fb79d4e

provide the web application for it and it should only have one index.html, style.css and script.js

Browse files
Files changed (4) hide show
  1. README.md +9 -6
  2. index.html +387 -19
  3. script.js +683 -0
  4. style.css +190 -19
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Codejudge Pro Competitive Programming Platform 1ggln
3
- emoji: 📈
4
- colorFrom: red
5
- colorTo: green
6
  sdk: static
7
- pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
1
  ---
2
+ title: CodeJudge Pro - Competitive Programming Platform ⚡
3
+ colorFrom: pink
4
+ colorTo: purple
 
5
  sdk: static
6
+ emoji: 💎
7
+ tags:
8
+ - deepsite-v4
9
  ---
10
 
11
+ # CodeJudge Pro - Competitive Programming Platform ⚡
12
+
13
+ This project has been created with [DeepSite](https://deepsite.hf.co) AI Vibe Coding.
index.html CHANGED
@@ -1,19 +1,387 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>CodeJudge Pro - Competitive Programming Platform</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.34.0/min/vs/loader.js"></script>
9
+ <link rel="stylesheet" href="style.css">
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
11
+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
12
+ </head>
13
+ <body class="bg-gray-950 text-gray-100 font-inter">
14
+ <!-- Navigation -->
15
+ <nav class="bg-gray-900 border-b border-gray-800 px-6 py-4">
16
+ <div class="max-w-7xl mx-auto flex items-center justify-between">
17
+ <div class="flex items-center space-x-2">
18
+ <div class="bg-gradient-to-r from-blue-500 to-purple-600 w-8 h-8 rounded-lg flex items-center justify-center">
19
+ <i class="fas fa-code text-white"></i>
20
+ </div>
21
+ <h1 class="text-xl font-bold bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-transparent">
22
+ CodeJudge Pro
23
+ </h1>
24
+ </div>
25
+
26
+ <div class="flex items-center space-x-4">
27
+ <div class="hidden md:flex space-x-6">
28
+ <a href="#" class="hover:text-blue-400 transition-colors">Problems</a>
29
+ <a href="#" class="hover:text-blue-400 transition-colors">Contests</a>
30
+ <a href="#" class="hover:text-blue-400 transition-colors">Leaderboard</a>
31
+ <a href="#" class="hover:text-blue-400 transition-colors">Discuss</a>
32
+ </div>
33
+
34
+ <div class="flex items-center space-x-3">
35
+ <div class="relative">
36
+ <div class="w-8 h-8 bg-gradient-to-r from-green-500 to-blue-500 rounded-full flex items-center justify-center cursor-pointer">
37
+ <span class="text-sm font-bold">JD</span>
38
+ </div>
39
+ </div>
40
+ <button class="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 px-4 py-2 rounded-lg font-medium transition-all">
41
+ Sign In
42
+ </button>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ </nav>
47
+
48
+ <!-- Main Container -->
49
+ <div class="max-w-7xl mx-auto px-4 py-6">
50
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
51
+ <!-- Problem Panel -->
52
+ <div class="lg:col-span-2 space-y-6">
53
+ <!-- Problem Header -->
54
+ <div class="bg-gray-900 rounded-xl border border-gray-800 p-6">
55
+ <div class="flex items-center justify-between mb-4">
56
+ <div>
57
+ <h2 class="text-2xl font-bold">Two Sum</h2>
58
+ <div class="flex items-center space-x-3 mt-2">
59
+ <span class="px-3 py-1 bg-green-900/30 text-green-400 rounded-full text-sm font-medium">
60
+ Easy
61
+ </span>
62
+ <span class="text-gray-400 text-sm">
63
+ <i class="fas fa-users mr-1"></i> 78.4% Accepted
64
+ </span>
65
+ <span class="text-gray-400 text-sm">
66
+ <i class="fas fa-clock mr-1"></i> 2 sec
67
+ </span>
68
+ <span class="text-gray-400 text-sm">
69
+ <i class="fas fa-memory mr-1"></i> 256 MB
70
+ </span>
71
+ </div>
72
+ </div>
73
+
74
+ <div class="flex space-x-3">
75
+ <button id="runBtn" class="px-4 py-2 bg-blue-900/50 hover:bg-blue-900 text-blue-300 hover:text-blue-200 rounded-lg border border-blue-800/50 transition-colors">
76
+ <i class="fas fa-play mr-2"></i>Run Code
77
+ </button>
78
+ <button id="submitBtn" class="px-4 py-2 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 rounded-lg font-medium transition-all">
79
+ <i class="fas fa-paper-plane mr-2"></i>Submit
80
+ </button>
81
+ </div>
82
+ </div>
83
+
84
+ <div class="flex border-b border-gray-800 mb-4">
85
+ <button class="tab-btn active px-4 py-3 border-b-2 border-blue-500 text-blue-400 font-medium" data-tab="description">
86
+ Description
87
+ </button>
88
+ <button class="tab-btn px-4 py-3 text-gray-400 hover:text-gray-300 font-medium" data-tab="solutions">
89
+ Solutions
90
+ </button>
91
+ <button class="tab-btn px-4 py-3 text-gray-400 hover:text-gray-300 font-medium" data-tab="submissions">
92
+ Submissions
93
+ </button>
94
+ </div>
95
+
96
+ <!-- Problem Description -->
97
+ <div id="description" class="tab-content active">
98
+ <div class="space-y-4">
99
+ <p class="text-gray-300">
100
+ Given an array of integers <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">nums</code> and an integer <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">target</code>, return indices of the two numbers such that they add up to <code class="bg-gray-800 px-2 py-1 rounded text-blue-300">target</code>.
101
+ </p>
102
+
103
+ <p class="text-gray-300">
104
+ You may assume that each input would have <strong>exactly one solution</strong>, and you may not use the same element twice.
105
+ </p>
106
+
107
+ <p class="text-gray-300">
108
+ You can return the answer in any order.
109
+ </p>
110
+
111
+ <div class="bg-gray-800/50 rounded-lg p-4 border border-gray-700">
112
+ <h4 class="font-bold text-lg mb-3">Example 1:</h4>
113
+ <div class="space-y-2">
114
+ <div class="flex">
115
+ <span class="text-gray-400 min-w-24">Input:</span>
116
+ <code class="bg-gray-900 px-3 py-1 rounded">nums = [2,7,11,15], target = 9</code>
117
+ </div>
118
+ <div class="flex">
119
+ <span class="text-gray-400 min-w-24">Output:</span>
120
+ <code class="bg-gray-900 px-3 py-1 rounded">[0,1]</code>
121
+ </div>
122
+ <div class="text-gray-400 text-sm">
123
+ <strong>Explanation:</strong> Because nums[0] + nums[1] == 9, we return [0, 1].
124
+ </div>
125
+ </div>
126
+ </div>
127
+
128
+ <div class="bg-gray-800/50 rounded-lg p-4 border border-gray-700">
129
+ <h4 class="font-bold text-lg mb-3">Example 2:</h4>
130
+ <div class="space-y-2">
131
+ <div class="flex">
132
+ <span class="text-gray-400 min-w-24">Input:</span>
133
+ <code class="bg-gray-900 px-3 py-1 rounded">nums = [3,2,4], target = 6</code>
134
+ </div>
135
+ <div class="flex">
136
+ <span class="text-gray-400 min-w-24">Output:</span>
137
+ <code class="bg-gray-900 px-3 py-1 rounded">[1,2]</code>
138
+ </div>
139
+ </div>
140
+ </div>
141
+
142
+ <div class="bg-gray-800/50 rounded-lg p-4 border border-gray-700">
143
+ <h4 class="font-bold text-lg mb-2">Constraints:</h4>
144
+ <ul class="list-disc list-inside space-y-1 text-gray-300">
145
+ <li><code class="bg-gray-900 px-1 py-0.5 rounded">2 <= nums.length <= 10^4</code></li>
146
+ <li><code class="bg-gray-900 px-1 py-0.5 rounded">-10^9 <= nums[i] <= 10^9</code></li>
147
+ <li><code class="bg-gray-900 px-1 py-0.5 rounded">-10^9 <= target <= 10^9</code></li>
148
+ <li><strong>Only one valid answer exists.</strong></li>
149
+ </ul>
150
+ </div>
151
+ </div>
152
+ </div>
153
+
154
+ <!-- Solutions Tab -->
155
+ <div id="solutions" class="tab-content hidden">
156
+ <div class="space-y-4">
157
+ <div class="bg-gray-800/50 rounded-lg p-4 border border-gray-700">
158
+ <h4 class="font-bold text-lg mb-3">Optimal Solution (Hash Map)</h4>
159
+ <p class="text-gray-300 mb-3">Time Complexity: O(n), Space Complexity: O(n)</p>
160
+ <pre class="bg-gray-900 p-4 rounded-lg overflow-x-auto text-sm">
161
+ class Solution {
162
+ public:
163
+ vector<int> twoSum(vector<int>& nums, int target) {
164
+ unordered_map<int, int> map;
165
+ for (int i = 0; i < nums.size(); i++) {
166
+ int complement = target - nums[i];
167
+ if (map.find(complement) != map.end()) {
168
+ return {map[complement], i};
169
+ }
170
+ map[nums[i]] = i;
171
+ }
172
+ return {};
173
+ }
174
+ };</pre>
175
+ </div>
176
+ </div>
177
+ </div>
178
+
179
+ <!-- Submissions Tab -->
180
+ <div id="submissions" class="tab-content hidden">
181
+ <div class="space-y-3">
182
+ <div class="flex items-center justify-between bg-gray-800/30 p-3 rounded-lg">
183
+ <div class="flex items-center space-x-3">
184
+ <div class="w-2 h-2 bg-green-500 rounded-full"></div>
185
+ <span class="font-mono text-sm">Accepted</span>
186
+ </div>
187
+ <div class="text-sm text-gray-400">2 seconds ago</div>
188
+ </div>
189
+ <div class="flex items-center justify-between bg-gray-800/30 p-3 rounded-lg">
190
+ <div class="flex items-center space-x-3">
191
+ <div class="w-2 h-2 bg-red-500 rounded-full"></div>
192
+ <span class="font-mono text-sm">Wrong Answer</span>
193
+ </div>
194
+ <div class="text-sm text-gray-400">5 minutes ago</div>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ </div>
199
+
200
+ <!-- Test Cases Section -->
201
+ <div class="bg-gray-900 rounded-xl border border-gray-800 p-6">
202
+ <h3 class="text-lg font-bold mb-4">Test Cases</h3>
203
+ <div class="space-y-4">
204
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
205
+ <div class="bg-gray-800/50 rounded-lg p-4">
206
+ <div class="flex items-center justify-between mb-2">
207
+ <span class="text-sm font-medium text-gray-300">Test Case 1</span>
208
+ <span class="px-2 py-1 bg-green-900/30 text-green-400 rounded text-xs">Visible</span>
209
+ </div>
210
+ <div class="space-y-2">
211
+ <div>
212
+ <span class="text-gray-400 text-sm">Input:</span>
213
+ <div class="bg-gray-900 p-2 rounded mt-1 font-mono text-sm">nums = [2,7,11,15]<br>target = 9</div>
214
+ </div>
215
+ <div>
216
+ <span class="text-gray-400 text-sm">Expected Output:</span>
217
+ <div class="bg-gray-900 p-2 rounded mt-1 font-mono text-sm">[0,1]</div>
218
+ </div>
219
+ </div>
220
+ </div>
221
+
222
+ <div class="bg-gray-800/50 rounded-lg p-4">
223
+ <div class="flex items-center justify-between mb-2">
224
+ <span class="text-sm font-medium text-gray-300">Test Case 2</span>
225
+ <span class="px-2 py-1 bg-red-900/30 text-red-400 rounded text-xs">Hidden</span>
226
+ </div>
227
+ <div class="space-y-2">
228
+ <div>
229
+ <span class="text-gray-400 text-sm">Input:</span>
230
+ <div class="bg-gray-900 p-2 rounded mt-1 font-mono text-sm">Hidden test case</div>
231
+ </div>
232
+ <div>
233
+ <span class="text-gray-400 text-sm">Expected Output:</span>
234
+ <div class="bg-gray-900 p-2 rounded mt-1 font-mono text-sm">Hidden</div>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+
240
+ <div class="flex items-center justify-between">
241
+ <div class="text-sm text-gray-400">
242
+ <i class="fas fa-info-circle mr-1"></i> 2 visible test cases, 5 hidden test cases
243
+ </div>
244
+ <button class="text-sm text-blue-400 hover:text-blue-300">
245
+ <i class="fas fa-plus mr-1"></i>Add Custom Test Case
246
+ </button>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ </div>
251
+
252
+ <!-- Code Editor Panel -->
253
+ <div class="space-y-6">
254
+ <!-- Editor Header -->
255
+ <div class="bg-gray-900 rounded-xl border border-gray-800 p-4">
256
+ <div class="flex items-center justify-between mb-4">
257
+ <h3 class="font-bold">Code Editor</h3>
258
+ <div class="flex items-center space-x-3">
259
+ <div class="relative group">
260
+ <select id="languageSelect" class="bg-gray-800 border border-gray-700 text-gray-300 rounded-lg px-3 py-2 appearance-none cursor-pointer">
261
+ <option value="cpp">C++ 17</option>
262
+ <option value="python">Python 3</option>
263
+ <option value="java">Java 17</option>
264
+ </select>
265
+ <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-400">
266
+ <i class="fas fa-chevron-down"></i>
267
+ </div>
268
+ </div>
269
+ <button id="resetBtn" class="px-3 py-2 bg-gray-800 hover:bg-gray-700 rounded-lg text-gray-300 hover:text-gray-100 transition-colors">
270
+ <i class="fas fa-redo"></i>
271
+ </button>
272
+ </div>
273
+ </div>
274
+
275
+ <!-- Code Editor Container -->
276
+ <div id="editorContainer" class="h-[500px] rounded-lg border border-gray-700 overflow-hidden">
277
+ <!-- Monaco Editor will be loaded here -->
278
+ </div>
279
+
280
+ <!-- Editor Status Bar -->
281
+ <div class="flex items-center justify-between mt-4 pt-4 border-t border-gray-800">
282
+ <div class="flex items-center space-x-4 text-sm text-gray-400">
283
+ <div class="flex items-center">
284
+ <i class="fas fa-code mr-2"></i>
285
+ <span id="lineCount">Line: 1</span>
286
+ </div>
287
+ <div class="flex items-center">
288
+ <i class="fas fa-font mr-2"></i>
289
+ <span id="charCount">Chars: 0</span>
290
+ </div>
291
+ </div>
292
+ <div class="flex items-center space-x-3">
293
+ <button id="formatBtn" class="px-3 py-1.5 bg-gray-800 hover:bg-gray-700 rounded text-sm transition-colors">
294
+ <i class="fas fa-broom mr-1"></i>Format
295
+ </button>
296
+ <button id="themeToggle" class="px-3 py-1.5 bg-gray-800 hover:bg-gray-700 rounded text-sm transition-colors">
297
+ <i class="fas fa-moon mr-1"></i>Dark
298
+ </button>
299
+ </div>
300
+ </div>
301
+ </div>
302
+
303
+ <!-- Compilation & Output Panel -->
304
+ <div class="bg-gray-900 rounded-xl border border-gray-800 overflow-hidden">
305
+ <div class="border-b border-gray-800">
306
+ <div class="flex">
307
+ <button class="output-tab active px-4 py-3 font-medium border-b-2 border-blue-500 text-blue-400" data-tab="output">
308
+ <i class="fas fa-terminal mr-2"></i>Output
309
+ </button>
310
+ <button class="output-tab px-4 py-3 font-medium text-gray-400 hover:text-gray-300" data-tab="console">
311
+ <i class="fas fa-code mr-2"></i>Console
312
+ </button>
313
+ </div>
314
+ </div>
315
+
316
+ <div id="outputPanel" class="p-4">
317
+ <!-- Execution Status -->
318
+ <div id="executionStatus" class="hidden mb-4">
319
+ <div class="flex items-center justify-between">
320
+ <div class="flex items-center space-x-2">
321
+ <div id="statusIcon" class="w-4 h-4 rounded-full bg-yellow-500 animate-pulse"></div>
322
+ <span id="statusText" class="font-medium">Compiling...</span>
323
+ </div>
324
+ <div id="timer" class="text-sm text-gray-400">0.0s</div>
325
+ </div>
326
+ <div id="progressBar" class="h-1 bg-gray-800 rounded-full mt-2 overflow-hidden">
327
+ <div class="h-full bg-blue-500 progress-animation"></div>
328
+ </div>
329
+ </div>
330
+
331
+ <!-- Results -->
332
+ <div id="resultsContainer" class="space-y-4">
333
+ <div class="text-center py-8 text-gray-500">
334
+ <i class="fas fa-play-circle text-3xl mb-3"></i>
335
+ <p class="text-sm">Click "Run Code" to execute your solution</p>
336
+ </div>
337
+ </div>
338
+
339
+ <!-- Console Output -->
340
+ <div id="consoleOutput" class="hidden font-mono text-sm">
341
+ <div class="bg-gray-800 rounded p-3 mb-2">
342
+ <span class="text-green-400">$</span> g++ -std=c++17 -O2 -o solution solution.cpp
343
+ </div>
344
+ <div class="bg-gray-800 rounded p-3">
345
+ <span class="text-green-400">$</span> ./solution &lt; test_input.txt
346
+ </div>
347
+ </div>
348
+ </div>
349
+ </div>
350
+ </div>
351
+ </div>
352
+ </div>
353
+
354
+ <!-- Toast Notification -->
355
+ <div id="toast" class="fixed bottom-6 right-6 bg-gray-900 border border-gray-700 rounded-lg p-4 shadow-xl transform translate-y-full transition-transform duration-300 z-50 max-w-md">
356
+ <div class="flex items-center">
357
+ <div id="toastIcon" class="w-6 h-6 rounded-full mr-3 flex items-center justify-center">
358
+ <i class="fas fa-info text-white text-xs"></i>
359
+ </div>
360
+ <div>
361
+ <h4 id="toastTitle" class="font-bold">Notification</h4>
362
+ <p id="toastMessage" class="text-sm text-gray-300">This is a toast message</p>
363
+ </div>
364
+ <button id="closeToast" class="ml-auto text-gray-400 hover:text-gray-200">
365
+ <i class="fas fa-times"></i>
366
+ </button>
367
+ </div>
368
+ </div>
369
+
370
+ <!-- Loading Overlay -->
371
+ <div id="loadingOverlay" class="fixed inset-0 bg-gray-950/80 flex items-center justify-center z-50 hidden">
372
+ <div class="bg-gray-900 rounded-xl border border-gray-800 p-8 max-w-md w-full mx-4">
373
+ <div class="flex flex-col items-center">
374
+ <div class="w-16 h-16 border-4 border-blue-500 border-t-transparent rounded-full animate-spin mb-4"></div>
375
+ <h3 class="text-xl font-bold mb-2">Judging Your Solution</h3>
376
+ <p class="text-gray-400 text-center mb-6">Compiling and running test cases...</p>
377
+ <div class="w-full bg-gray-800 rounded-full h-2 overflow-hidden">
378
+ <div class="h-full bg-gradient-to-r from-blue-500 to-purple-600 progress-animation-wide"></div>
379
+ </div>
380
+ </div>
381
+ </div>
382
+ </div>
383
+
384
+ <script src="script.js"></script>
385
+ <script src="https://deepsite.hf.co/deepsite-badge.js"></script>
386
+ </body>
387
+ </html>
script.js ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // CodeJudge Pro - Main Application Script
2
+
3
+ document.addEventListener('DOMContentLoaded', function() {
4
+ // Initialize variables
5
+ let editor;
6
+ let isDarkTheme = true;
7
+ let currentLanguage = 'cpp';
8
+ let isJudging = false;
9
+ let submissionQueue = [];
10
+ let testCases = [];
11
+ let mockResults = [];
12
+
13
+ // DOM Elements
14
+ const runBtn = document.getElementById('runBtn');
15
+ const submitBtn = document.getElementById('submitBtn');
16
+ const resetBtn = document.getElementById('resetBtn');
17
+ const formatBtn = document.getElementById('formatBtn');
18
+ const themeToggle = document.getElementById('themeToggle');
19
+ const languageSelect = document.getElementById('languageSelect');
20
+ const lineCount = document.getElementById('lineCount');
21
+ const charCount = document.getElementById('charCount');
22
+ const executionStatus = document.getElementById('executionStatus');
23
+ const resultsContainer = document.getElementById('resultsContainer');
24
+ const consoleOutput = document.getElementById('consoleOutput');
25
+ const outputTabs = document.querySelectorAll('.output-tab');
26
+ const toast = document.getElementById('toast');
27
+ const closeToast = document.getElementById('closeToast');
28
+ const loadingOverlay = document.getElementById('loadingOverlay');
29
+ const tabButtons = document.querySelectorAll('.tab-btn');
30
+ const tabContents = document.querySelectorAll('.tab-content');
31
+
32
+ // Default C++ template code
33
+ const cppTemplate = `#include <iostream>
34
+ #include <vector>
35
+ #include <unordered_map>
36
+ using namespace std;
37
+
38
+ class Solution {
39
+ public:
40
+ vector<int> twoSum(vector<int>& nums, int target) {
41
+ unordered_map<int, int> map;
42
+ for (int i = 0; i < nums.size(); i++) {
43
+ int complement = target - nums[i];
44
+ if (map.find(complement) != map.end()) {
45
+ return {map[complement], i};
46
+ }
47
+ map[nums[i]] = i;
48
+ }
49
+ return {};
50
+ }
51
+ };
52
+
53
+ int main() {
54
+ Solution sol;
55
+
56
+ // Example test case
57
+ vector<int> nums = {2, 7, 11, 15};
58
+ int target = 9;
59
+
60
+ vector<int> result = sol.twoSum(nums, target);
61
+
62
+ // Output format required by judge
63
+ cout << "[";
64
+ for (int i = 0; i < result.size(); i++) {
65
+ cout << result[i];
66
+ if (i < result.size() - 1) {
67
+ cout << ",";
68
+ }
69
+ }
70
+ cout << "]" << endl;
71
+
72
+ return 0;
73
+ }`;
74
+
75
+ // Mock test cases for simulation
76
+ const mockTestCases = [
77
+ {
78
+ id: 1,
79
+ input: "nums = [2,7,11,15]\ntarget = 9",
80
+ expected: "[0,1]",
81
+ isHidden: false,
82
+ description: "Simple case with early match"
83
+ },
84
+ {
85
+ id: 2,
86
+ input: "nums = [3,2,4]\ntarget = 6",
87
+ expected: "[1,2]",
88
+ isHidden: false,
89
+ description: "Match not at beginning"
90
+ },
91
+ {
92
+ id: 3,
93
+ input: "nums = [3,3]\ntarget = 6",
94
+ expected: "[0,1]",
95
+ isHidden: true,
96
+ description: "Duplicate numbers"
97
+ },
98
+ {
99
+ id: 4,
100
+ input: "nums = [1,2,3,4,5,6,7,8,9,10]\ntarget = 19",
101
+ expected: "[8,9]",
102
+ isHidden: true,
103
+ description: "Large array, match at end"
104
+ },
105
+ {
106
+ id: 5,
107
+ input: "nums = [-1,-2,-3,-4,-5]\ntarget = -8",
108
+ expected: "[2,4]",
109
+ isHidden: true,
110
+ description: "Negative numbers"
111
+ }
112
+ ];
113
+
114
+ // Mock submission results for simulation
115
+ const mockSubmissionResults = [
116
+ {
117
+ id: 1,
118
+ status: 'accepted',
119
+ time: 12,
120
+ memory: 8560,
121
+ message: 'All test cases passed',
122
+ testResults: [
123
+ {caseId: 1, passed: true, time: 4, output: '[0,1]'},
124
+ {caseId: 2, passed: true, time: 3, output: '[1,2]'},
125
+ {caseId: 3, passed: true, time: 5, output: '[0,1]'},
126
+ {caseId: 4, passed: true, time: 7, output: '[8,9]'},
127
+ {caseId: 5, passed: true, time: 6, output: '[2,4]'}
128
+ ]
129
+ },
130
+ {
131
+ id: 2,
132
+ status: 'wrong_answer',
133
+ time: 8,
134
+ memory: 7520,
135
+ message: 'Test case 2 failed',
136
+ testResults: [
137
+ {caseId: 1, passed: true, time: 3, output: '[0,1]'},
138
+ {caseId: 2, passed: false, time: 5, output: '[0,2]'},
139
+ {caseId: 3, passed: false, time: 2, output: '[0,0]'}
140
+ ]
141
+ },
142
+ {
143
+ id: 3,
144
+ status: 'compilation_error',
145
+ time: 0,
146
+ memory: 0,
147
+ message: "error: expected ';' before '}' token",
148
+ testResults: []
149
+ },
150
+ {
151
+ id: 4,
152
+ status: 'runtime_error',
153
+ time: 15,
154
+ memory: 12560,
155
+ message: 'Segmentation fault (core dumped)',
156
+ testResults: [
157
+ {caseId: 1, passed: false, time: 15, output: ''}
158
+ ]
159
+ },
160
+ {
161
+ id: 5,
162
+ status: 'time_limit_exceeded',
163
+ time: 2000,
164
+ memory: 12400,
165
+ message: 'Time limit exceeded on test case 3',
166
+ testResults: [
167
+ {caseId: 1, passed: true, time: 5, output: '[0,1]'},
168
+ {caseId: 2, passed: true, time: 7, output: '[1,2]'},
169
+ {caseId: 3, passed: false, time: 2000, output: ''}
170
+ ]
171
+ }
172
+ ];
173
+
174
+ // Initialize Monaco Editor
175
+ function initializeEditor() {
176
+ require.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.34.0/min/vs' } });
177
+
178
+ require(['vs/editor/editor.main'], function() {
179
+ editor = monaco.editor.create(document.getElementById('editorContainer'), {
180
+ value: cppTemplate,
181
+ language: 'cpp',
182
+ theme: 'vs-dark',
183
+ fontSize: 14,
184
+ fontFamily: "'JetBrains Mono', monospace",
185
+ lineNumbers: 'on',
186
+ roundedSelection: false,
187
+ scrollBeyondLastLine: false,
188
+ readOnly: false,
189
+ automaticLayout: true,
190
+ minimap: { enabled: false },
191
+ wordWrap: 'on',
192
+ wrappingIndent: 'indent',
193
+ renderLineHighlight: 'all',
194
+ cursorBlinking: 'smooth',
195
+ cursorSmoothCaretAnimation: 'on',
196
+ formatOnType: true,
197
+ formatOnPaste: true,
198
+ suggestOnTriggerCharacters: true,
199
+ acceptSuggestionOnEnter: 'on',
200
+ scrollbar: {
201
+ vertical: 'visible',
202
+ horizontal: 'visible',
203
+ useShadows: false
204
+ }
205
+ });
206
+
207
+ // Update line and character counts
208
+ updateEditorStats();
209
+
210
+ // Listen to editor changes
211
+ editor.onDidChangeModelContent(function() {
212
+ updateEditorStats();
213
+ });
214
+ });
215
+ }
216
+
217
+ // Update editor line and character count
218
+ function updateEditorStats() {
219
+ if (!editor) return;
220
+
221
+ const model = editor.getModel();
222
+ if (model) {
223
+ const lineCountValue = model.getLineCount();
224
+ const charCountValue = model.getValueLength();
225
+
226
+ lineCount.textContent = `Line: ${lineCountValue}`;
227
+ charCount.textContent = `Chars: ${charCountValue}`;
228
+ }
229
+ }
230
+
231
+ // Show toast notification
232
+ function showToast(type, title, message, duration = 4000) {
233
+ const icon = toast.querySelector('#toastIcon');
234
+ const titleEl = toast.querySelector('#toastTitle');
235
+ const messageEl = toast.querySelector('#toastMessage');
236
+
237
+ // Set toast style based on type
238
+ switch(type) {
239
+ case 'success':
240
+ icon.className = 'w-6 h-6 rounded-full mr-3 flex items-center justify-center bg-green-500';
241
+ icon.innerHTML = '<i class="fas fa-check text-white text-xs"></i>';
242
+ break;
243
+ case 'error':
244
+ icon.className = 'w-6 h-6 rounded-full mr-3 flex items-center justify-center bg-red-500';
245
+ icon.innerHTML = '<i class="fas fa-exclamation text-white text-xs"></i>';
246
+ break;
247
+ case 'warning':
248
+ icon.className = 'w-6 h-6 rounded-full mr-3 flex items-center justify-center bg-yellow-500';
249
+ icon.innerHTML = '<i class="fas fa-exclamation-triangle text-white text-xs"></i>';
250
+ break;
251
+ case 'info':
252
+ default:
253
+ icon.className = 'w-6 h-6 rounded-full mr-3 flex items-center justify-center bg-blue-500';
254
+ icon.innerHTML = '<i class="fas fa-info text-white text-xs"></i>';
255
+ }
256
+
257
+ titleEl.textContent = title;
258
+ messageEl.textContent = message;
259
+
260
+ // Show toast with animation
261
+ toast.classList.remove('translate-y-full');
262
+ toast.classList.add('translate-y-0');
263
+
264
+ // Auto hide after duration
265
+ setTimeout(() => {
266
+ toast.classList.remove('translate-y-0');
267
+ toast.classList.add('translate-y-full');
268
+ }, duration);
269
+ }
270
+
271
+ // Simulate code execution
272
+ function simulateExecution(isSubmit = false) {
273
+ if (isJudging) {
274
+ showToast('warning', 'Already Judging', 'Please wait for current submission to complete');
275
+ return;
276
+ }
277
+
278
+ isJudging = true;
279
+ loadingOverlay.classList.remove('hidden');
280
+
281
+ // Get code from editor
282
+ const code = editor.getValue();
283
+
284
+ // Reset results
285
+ resultsContainer.innerHTML = '';
286
+
287
+ // Show execution status
288
+ executionStatus.classList.remove('hidden');
289
+ const statusText = document.getElementById('statusText');
290
+ const statusIcon = document.getElementById('statusIcon');
291
+ const timer = document.getElementById('timer');
292
+
293
+ // Simulate compilation phase
294
+ statusText.textContent = 'Compiling...';
295
+ statusIcon.className = 'w-4 h-4 rounded-full bg-yellow-500 animate-pulse';
296
+
297
+ let timeElapsed = 0;
298
+ const timerInterval = setInterval(() => {
299
+ timeElapsed += 0.1;
300
+ timer.textContent = `${timeElapsed.toFixed(1)}s`;
301
+ }, 100);
302
+
303
+ // Simulate different phases
304
+ setTimeout(() => {
305
+ statusText.textContent = 'Running Test Cases...';
306
+ statusIcon.className = 'w-4 h-4 rounded-full bg-blue-500 animate-pulse';
307
+
308
+ setTimeout(() => {
309
+ // Generate random result for simulation
310
+ const resultIndex = isSubmit ?
311
+ (Math.random() > 0.7 ? 0 : Math.floor(Math.random() * (mockSubmissionResults.length - 1)) + 1) :
312
+ 0; // Always show success for Run button
313
+
314
+ const result = mockSubmissionResults[resultIndex];
315
+
316
+ // Show final result
317
+ statusText.textContent = getStatusDisplayName(result.status);
318
+ statusIcon.className = `w-4 h-4 rounded-full ${getStatusColor(result.status)}`;
319
+ statusIcon.classList.remove('animate-pulse');
320
+
321
+ clearInterval(timerInterval);
322
+ timer.textContent = `${(timeElapsed + 0.5).toFixed(1)}s`;
323
+
324
+ // Display results
325
+ displayResults(result, isSubmit);
326
+
327
+ // Show toast notification
328
+ showResultToast(result.status, result.message);
329
+
330
+ // Hide loading overlay
331
+ setTimeout(() => {
332
+ loadingOverlay.classList.add('hidden');
333
+ isJudging = false;
334
+ }, 500);
335
+
336
+ }, 1500);
337
+ }, 1000);
338
+ }
339
+
340
+ // Display execution results
341
+ function displayResults(result, showAllTests = false) {
342
+ resultsContainer.innerHTML = '';
343
+
344
+ // Result header
345
+ const resultHeader = document.createElement('div');
346
+ resultHeader.className = `flex items-center justify-between p-4 rounded-lg border ${getStatusBgClass(result.status)}`;
347
+
348
+ resultHeader.innerHTML = `
349
+ <div class="flex items-center space-x-3">
350
+ <div class="w-4 h-4 rounded-full ${getStatusColor(result.status)}"></div>
351
+ <div>
352
+ <h4 class="font-bold">${getStatusDisplayName(result.status)}</h4>
353
+ <p class="text-sm text-gray-400">${result.message}</p>
354
+ </div>
355
+ </div>
356
+ <div class="text-right">
357
+ <div class="text-sm text-gray-300">${result.time} ms</div>
358
+ <div class="text-sm text-gray-400">${result.memory} KB</div>
359
+ </div>
360
+ `;
361
+
362
+ resultsContainer.appendChild(resultHeader);
363
+
364
+ // Test case results (show only first 2 for run, all for submit)
365
+ const testsToShow = showAllTests ? result.testResults : result.testResults.slice(0, 2);
366
+
367
+ if (testsToShow.length > 0) {
368
+ const testsHeader = document.createElement('div');
369
+ testsHeader.className = 'mt-4 mb-2';
370
+ testsHeader.innerHTML = `<h5 class="font-medium">Test Cases ${showAllTests ? '' : '(Sample)'}</h5>`;
371
+ resultsContainer.appendChild(testsHeader);
372
+
373
+ testsToShow.forEach(test => {
374
+ const testElement = document.createElement('div');
375
+ testElement.className = `test-case-card p-4 rounded-lg border mb-3 ${test.passed ? 'border-green-800/50 bg-green-900/20' : 'border-red-800/50 bg-red-900/20'}`;
376
+
377
+ testElement.innerHTML = `
378
+ <div class="flex items-center justify-between mb-2">
379
+ <div class="flex items-center space-x-2">
380
+ <div class="w-3 h-3 rounded-full ${test.passed ? 'bg-green-500' : 'bg-red-500'}"></div>
381
+ <span class="font-medium">Test Case ${test.caseId}</span>
382
+ </div>
383
+ <div class="text-sm text-gray-400">${test.time} ms</div>
384
+ </div>
385
+ ${!test.passed ? `
386
+ <div class="mt-3 pt-3 border-t border-gray-800">
387
+ <div class="text-sm text-gray-400 mb-1">Output:</div>
388
+ <div class="bg-gray-900 p-2 rounded font-mono text-sm">${test.output || 'No output'}</div>
389
+ <div class="text-sm text-gray-400 mt-2 mb-1">Expected:</div>
390
+ <div class="bg-gray-900 p-2 rounded font-mono text-sm">${mockTestCases.find(tc => tc.id === test.caseId)?.expected || 'N/A'}</div>
391
+ </div>
392
+ ` : ''}
393
+ `;
394
+
395
+ resultsContainer.appendChild(testElement);
396
+ });
397
+
398
+ if (!showAllTests && result.testResults.length > 2) {
399
+ const moreTests = document.createElement('div');
400
+ moreTests.className = 'text-center text-sm text-gray-500 py-2';
401
+ moreTests.textContent = `+ ${result.testResults.length - 2} more test cases hidden`;
402
+ resultsContainer.appendChild(moreTests);
403
+ }
404
+ }
405
+
406
+ // Add stats if accepted
407
+ if (result.status === 'accepted') {
408
+ const stats = document.createElement('div');
409
+ stats.className = 'mt-4 p-4 bg-gray-800/30 rounded-lg';
410
+
411
+ const percentile = Math.floor(Math.random() * 20) + 70; // Random percentile between 70-90
412
+ stats.innerHTML = `
413
+ <h5 class="font-medium mb-2">Performance</h5>
414
+ <div class="grid grid-cols-2 gap-4">
415
+ <div>
416
+ <div class="text-sm text-gray-400">Time</div>
417
+ <div class="text-lg font-bold ${result.time < 50 ? 'text-green-400' : result.time < 100 ? 'text-yellow-400' : 'text-red-400'}">${result.time} ms</div>
418
+ <div class="text-xs text-gray-500">Beats ${percentile}% of submissions</div>
419
+ </div>
420
+ <div>
421
+ <div class="text-sm text-gray-400">Memory</div>
422
+ <div class="text-lg font-bold ${result.memory < 10000 ? 'text-green-400' : result.memory < 20000 ? 'text-yellow-400' : 'text-red-400'}">${(result.memory / 1024).toFixed(1)} MB</div>
423
+ <div class="text-xs text-gray-500">Beats ${percentile - 10}% of submissions</div>
424
+ </div>
425
+ </div>
426
+ `;
427
+
428
+ resultsContainer.appendChild(stats);
429
+ }
430
+ }
431
+
432
+ // Get status display name
433
+ function getStatusDisplayName(status) {
434
+ const statusMap = {
435
+ 'accepted': 'Accepted',
436
+ 'wrong_answer': 'Wrong Answer',
437
+ 'compilation_error': 'Compilation Error',
438
+ 'runtime_error': 'Runtime Error',
439
+ 'time_limit_exceeded': 'Time Limit Exceeded',
440
+ 'memory_limit_exceeded': 'Memory Limit Exceeded'
441
+ };
442
+ return statusMap[status] || status;
443
+ }
444
+
445
+ // Get status color class
446
+ function getStatusColor(status) {
447
+ const colorMap = {
448
+ 'accepted': 'bg-green-500',
449
+ 'wrong_answer': 'bg-red-500',
450
+ 'compilation_error': 'bg-yellow-500',
451
+ 'runtime_error': 'bg-orange-500',
452
+ 'time_limit_exceeded': 'bg-purple-500',
453
+ 'memory_limit_exceeded': 'bg-indigo-500'
454
+ };
455
+ return colorMap[status] || 'bg-gray-500';
456
+ }
457
+
458
+ // Get status background class
459
+ function getStatusBgClass(status) {
460
+ const bgMap = {
461
+ 'accepted': 'border-green-800/50 bg-green-900/20',
462
+ 'wrong_answer': 'border-red-800/50 bg-red-900/20',
463
+ 'compilation_error': 'border-yellow-800/50 bg-yellow-900/20',
464
+ 'runtime_error': 'border-orange-800/50 bg-orange-900/20',
465
+ 'time_limit_exceeded': 'border-purple-800/50 bg-purple-900/20',
466
+ 'memory_limit_exceeded': 'border-indigo-800/50 bg-indigo-900/20'
467
+ };
468
+ return bgMap[status] || 'border-gray-800/50 bg-gray-900/20';
469
+ }
470
+
471
+ // Show result toast
472
+ function showResultToast(status, message) {
473
+ const typeMap = {
474
+ 'accepted': 'success',
475
+ 'wrong_answer': 'error',
476
+ 'compilation_error': 'warning',
477
+ 'runtime_error': 'error',
478
+ 'time_limit_exceeded': 'warning',
479
+ 'memory_limit_exceeded': 'warning'
480
+ };
481
+
482
+ showToast(typeMap[status] || 'info', getStatusDisplayName(status), message);
483
+ }
484
+
485
+ // Format code (simplified)
486
+ function formatCode() {
487
+ if (!editor) return;
488
+
489
+ const code = editor.getValue();
490
+
491
+ // Simple formatting simulation
492
+ let formatted = code
493
+ .replace(/\t/g, ' ')
494
+ .replace(/\n\s*\n\s*\n/g, '\n\n');
495
+
496
+ editor.setValue(formatted);
497
+ showToast('success', 'Code Formatted', 'Your code has been formatted successfully');
498
+ }
499
+
500
+ // Toggle theme
501
+ function toggleTheme() {
502
+ isDarkTheme = !isDarkTheme;
503
+
504
+ if (editor) {
505
+ monaco.editor.setTheme(isDarkTheme ? 'vs-dark' : 'vs');
506
+ }
507
+
508
+ themeToggle.innerHTML = isDarkTheme ?
509
+ '<i class="fas fa-moon mr-1"></i>Dark' :
510
+ '<i class="fas fa-sun mr-1"></i>Light';
511
+
512
+ document.body.classList.toggle('light-theme', !isDarkTheme);
513
+
514
+ showToast('info', 'Theme Changed', `Switched to ${isDarkTheme ? 'Dark' : 'Light'} theme`);
515
+ }
516
+
517
+ // Reset editor to template
518
+ function resetEditor() {
519
+ if (!editor) return;
520
+
521
+ const language = languageSelect.value;
522
+ let template = cppTemplate;
523
+
524
+ if (language === 'python') {
525
+ template = `class Solution:
526
+ def twoSum(self, nums, target):
527
+ num_map = {}
528
+ for i, num in enumerate(nums):
529
+ complement = target - num
530
+ if complement in num_map:
531
+ return [num_map[complement], i]
532
+ num_map[num] = i
533
+ return []
534
+
535
+ if __name__ == "__main__":
536
+ sol = Solution()
537
+ nums = [2, 7, 11, 15]
538
+ target = 9
539
+ result = sol.twoSum(nums, target)
540
+ print(result)`;
541
+ } else if (language === 'java') {
542
+ template = `import java.util.*;
543
+
544
+ class Solution {
545
+ public int[] twoSum(int[] nums, int target) {
546
+ Map<Integer, Integer> map = new HashMap<>();
547
+ for (int i = 0; i < nums.length; i++) {
548
+ int complement = target - nums[i];
549
+ if (map.containsKey(complement)) {
550
+ return new int[] { map.get(complement), i };
551
+ }
552
+ map.put(nums[i], i);
553
+ }
554
+ return new int[0];
555
+ }
556
+
557
+ public static void main(String[] args) {
558
+ Solution sol = new Solution();
559
+ int[] nums = {2, 7, 11, 15};
560
+ int target = 9;
561
+ int[] result = sol.twoSum(nums, target);
562
+ System.out.println(Arrays.toString(result));
563
+ }
564
+ }`;
565
+ }
566
+
567
+ editor.setValue(template);
568
+ showToast('info', 'Code Reset', 'Editor has been reset to default template');
569
+ }
570
+
571
+ // Change language
572
+ function changeLanguage() {
573
+ const language = languageSelect.value;
574
+ currentLanguage = language;
575
+
576
+ if (editor) {
577
+ monaco.editor.setModelLanguage(editor.getModel(), language);
578
+ }
579
+
580
+ resetEditor();
581
+ showToast('info', 'Language Changed', `Switched to ${languageSelect.options[languageSelect.selectedIndex].text}`);
582
+ }
583
+
584
+ // Tab switching
585
+ function setupTabs() {
586
+ tabButtons.forEach(button => {
587
+ button.addEventListener('click', function() {
588
+ const tabId = this.getAttribute('data-tab');
589
+
590
+ // Update active tab button
591
+ tabButtons.forEach(btn => {
592
+ btn.classList.remove('active', 'border-blue-500', 'text-blue-400');
593
+ btn.classList.add('text-gray-400');
594
+ });
595
+
596
+ this.classList.add('active', 'border-blue-500', 'text-blue-400');
597
+ this.classList.remove('text-gray-400');
598
+
599
+ // Show active tab content
600
+ tabContents.forEach(content => {
601
+ content.classList.remove('active');
602
+ content.classList.add('hidden');
603
+ });
604
+
605
+ document.getElementById(tabId).classList.add('active');
606
+ document.getElementById(tabId).classList.remove('hidden');
607
+ });
608
+ });
609
+ }
610
+
611
+ // Output tab switching
612
+ function setupOutputTabs() {
613
+ outputTabs.forEach(tab => {
614
+ tab.addEventListener('click', function() {
615
+ const tabId = this.getAttribute('data-tab');
616
+
617
+ // Update active output tab
618
+ outputTabs.forEach(t => {
619
+ t.classList.remove('active', 'border-blue-500', 'text-blue-400');
620
+ t.classList.add('text-gray-400');
621
+ });
622
+
623
+ this.classList.add('active', 'border-blue-500', 'text-blue-400');
624
+ this.classList.remove('text-gray-400');
625
+
626
+ // Show console or output
627
+ if (tabId === 'console') {
628
+ consoleOutput.classList.remove('hidden');
629
+ } else {
630
+ consoleOutput.classList.add('hidden');
631
+ }
632
+ });
633
+ });
634
+ }
635
+
636
+ // Initialize everything
637
+ function init() {
638
+ initializeEditor();
639
+ setupTabs();
640
+ setupOutputTabs();
641
+
642
+ // Event listeners
643
+ runBtn.addEventListener('click', () => simulateExecution(false));
644
+ submitBtn.addEventListener('click', () => simulateExecution(true));
645
+ resetBtn.addEventListener('click', resetEditor);
646
+ formatBtn.addEventListener('click', formatCode);
647
+ themeToggle.addEventListener('click', toggleTheme);
648
+ languageSelect.addEventListener('change', changeLanguage);
649
+ closeToast.addEventListener('click', () => {
650
+ toast.classList.remove('translate-y-0');
651
+ toast.classList.add('translate-y-full');
652
+ });
653
+
654
+ // Keyboard shortcuts
655
+ document.addEventListener('keydown', function(e) {
656
+ // Ctrl+Enter to submit
657
+ if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
658
+ e.preventDefault();
659
+ simulateExecution(true);
660
+ }
661
+
662
+ // Ctrl+R to run
663
+ if ((e.ctrlKey || e.metaKey) && e.key === 'r' && !e.shiftKey) {
664
+ e.preventDefault();
665
+ simulateExecution(false);
666
+ }
667
+
668
+ // Ctrl+Shift+F to format
669
+ if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'F') {
670
+ e.preventDefault();
671
+ formatCode();
672
+ }
673
+ });
674
+
675
+ // Initial toast
676
+ setTimeout(() => {
677
+ showToast('info', 'Welcome to CodeJudge Pro', 'Start by writing your solution and clicking "Run Code" to test it');
678
+ }, 1000);
679
+ }
680
+
681
+ // Start the application
682
+ init();
683
+ });
style.css CHANGED
@@ -1,28 +1,199 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
 
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
 
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
 
 
 
 
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Custom Styles for CodeJudge Pro */
2
+
3
+ @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');
4
+
5
+ /* Scrollbar Styling */
6
+ ::-webkit-scrollbar {
7
+ width: 8px;
8
+ height: 8px;
9
+ }
10
+
11
+ ::-webkit-scrollbar-track {
12
+ background: #1f2937;
13
+ }
14
+
15
+ ::-webkit-scrollbar-thumb {
16
+ background: #4b5563;
17
+ border-radius: 4px;
18
+ }
19
+
20
+ ::-webkit-scrollbar-thumb:hover {
21
+ background: #6b7280;
22
+ }
23
+
24
+ /* Monaco Editor Customization */
25
+ .monaco-editor {
26
+ border-radius: 0.5rem;
27
+ }
28
+
29
+ .monaco-editor .margin {
30
+ background-color: #111827 !important;
31
+ }
32
+
33
+ /* Code Highlighting */
34
+ code {
35
+ font-family: 'JetBrains Mono', monospace;
36
+ font-size: 0.875rem;
37
  }
38
 
39
+ /* Progress Animations */
40
+ .progress-animation {
41
+ width: 30%;
42
+ animation: progress 1.5s ease-in-out infinite alternate;
43
  }
44
 
45
+ .progress-animation-wide {
46
+ width: 60%;
47
+ animation: progress-wide 2s ease-in-out infinite alternate;
 
 
48
  }
49
 
50
+ @keyframes progress {
51
+ 0% {
52
+ transform: translateX(-100%);
53
+ }
54
+ 100% {
55
+ transform: translateX(300%);
56
+ }
57
  }
58
 
59
+ @keyframes progress-wide {
60
+ 0% {
61
+ transform: translateX(-60%);
62
+ }
63
+ 100% {
64
+ transform: translateX(160%);
65
+ }
66
  }
67
+
68
+ /* Tab Transitions */
69
+ .tab-content {
70
+ transition: opacity 0.2s ease;
71
+ }
72
+
73
+ /* Status Colors */
74
+ .status-accepted {
75
+ background-color: rgba(34, 197, 94, 0.1);
76
+ border-color: rgba(34, 197, 94, 0.3);
77
+ }
78
+
79
+ .status-wrong-answer {
80
+ background-color: rgba(239, 68, 68, 0.1);
81
+ border-color: rgba(239, 68, 68, 0.3);
82
+ }
83
+
84
+ .status-compilation-error {
85
+ background-color: rgba(245, 158, 11, 0.1);
86
+ border-color: rgba(245, 158, 11, 0.3);
87
+ }
88
+
89
+ .status-runtime-error {
90
+ background-color: rgba(249, 115, 22, 0.1);
91
+ border-color: rgba(249, 115, 22, 0.3);
92
+ }
93
+
94
+ .status-time-limit {
95
+ background-color: rgba(168, 85, 247, 0.1);
96
+ border-color: rgba(168, 85, 247, 0.3);
97
+ }
98
+
99
+ .status-memory-limit {
100
+ background-color: rgba(139, 92, 246, 0.1);
101
+ border-color: rgba(139, 92, 246, 0.3);
102
+ }
103
+
104
+ /* Test Case Result Cards */
105
+ .test-case-card {
106
+ transition: all 0.2s ease;
107
+ }
108
+
109
+ .test-case-card:hover {
110
+ transform: translateY(-2px);
111
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
112
+ }
113
+
114
+ /* Custom Checkbox */
115
+ .custom-checkbox {
116
+ appearance: none;
117
+ width: 18px;
118
+ height: 18px;
119
+ border: 2px solid #4b5563;
120
+ border-radius: 4px;
121
+ background-color: #111827;
122
+ cursor: pointer;
123
+ position: relative;
124
+ }
125
+
126
+ .custom-checkbox:checked {
127
+ background-color: #3b82f6;
128
+ border-color: #3b82f6;
129
+ }
130
+
131
+ .custom-checkbox:checked::after {
132
+ content: '✓';
133
+ position: absolute;
134
+ color: white;
135
+ font-size: 12px;
136
+ font-weight: bold;
137
+ top: 50%;
138
+ left: 50%;
139
+ transform: translate(-50%, -50%);
140
+ }
141
+
142
+ /* Editor Theme Variables */
143
+ :root {
144
+ --editor-bg: #111827;
145
+ --editor-border: #374151;
146
+ --editor-text: #e5e7eb;
147
+ }
148
+
149
+ .light-theme {
150
+ --editor-bg: #f9fafb;
151
+ --editor-border: #d1d5db;
152
+ --editor-text: #111827;
153
+ }
154
+
155
+ /* Animation for new submissions */
156
+ @keyframes pulse-submission {
157
+ 0%, 100% {
158
+ opacity: 1;
159
+ }
160
+ 50% {
161
+ opacity: 0.7;
162
+ }
163
+ }
164
+
165
+ .pulse-submission {
166
+ animation: pulse-submission 1.5s ease-in-out infinite;
167
+ }
168
+
169
+ /* Result Badge Animation */
170
+ @keyframes badge-pop {
171
+ 0% {
172
+ transform: scale(0.8);
173
+ opacity: 0;
174
+ }
175
+ 70% {
176
+ transform: scale(1.1);
177
+ }
178
+ 100% {
179
+ transform: scale(1);
180
+ opacity: 1;
181
+ }
182
+ }
183
+
184
+ .badge-pop {
185
+ animation: badge-pop 0.3s ease-out;
186
+ }
187
+
188
+ /* Responsive Adjustments */
189
+ @media (max-width: 1024px) {
190
+ .editor-container {
191
+ height: 400px;
192
+ }
193
+ }
194
+
195
+ @media (max-width: 768px) {
196
+ .editor-container {
197
+ height: 350px;
198
+ }
199
+ }