File size: 11,995 Bytes
0f609e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28a72ed
0f609e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28a72ed
0f609e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d378c8c
 
 
 
 
0f609e5
 
d378c8c
 
 
 
 
 
 
 
0f609e5
 
 
d378c8c
 
0f609e5
 
d378c8c
0f609e5
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html>
<html>

<head>
    <style>
        pre {
            white-space: pre-wrap;
            /* Wraps the text */
            word-break: break-word;
            /* Ensures words break to prevent overflow */
            background-color: #f4f4f4;
            /* Light grey background */
            padding: 2px;
            /* Padding around the text */
            border-radius: 2px;
            /* Rounded corners */
            border: 1px solid #ccc;
            /* Light grey border */
        }

        .container {
            display: flex;
            /* Use flexbox to layout children */
            justify-content: space-between;
            /* Space between the children */
            margin-bottom: 10px;
            /* Space between each container */
            background-color: #ddd;
            /* Debug: background color */
        }

        .sub-container {
            flex: 1;
            /* Each sub-container takes equal width */
            padding: 20px;
            /* Padding inside each sub-container */
            background-color: #f4f4f4;
            /* Background color */
            border-radius: 2px;
            /* Rounded corners */
            border: 1px solid #ccc;
            /* Border */
            margin: 0 10px;
            /* Margin between sub-containers */
        }

        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }

        #checkboxes {
            margin-bottom: 20px;
        }

        .model-checkbox+label {
            margin-right: 10px;
            padding: 5px 10px;
            background-color: #e7e7e7;
            border-radius: 5px;
            cursor: pointer;
            user-select: none;
        }

        .model-checkbox {
            display: none;
            /* Hide the default checkbox */
        }

        .model-checkbox:checked+label {
            background-color: #d0e6a5;
            color: #0b4d03;
        }

        .model {
            border: 1px solid black;
            padding: 10px;
        }

        .counter {
            margin-top: 20px;
        }

        .passed code.hljs {
            background-color: #e6ffe6 !important;
            /* light green */
            color: black !important;
        }

        .failed code.hljs {
            background-color: #ffe6e6 !important;
            /* light red */
            color: black !important;
        }

        .solution {
            display: none;
            /* Hide all solutions by default */
        }

        .solution.active {
            display: block;
            /* Only show the active solution */
        }

        .button-container {
            text-align: center;
            /* Center the button container */
            margin-top: 20px;
            /* Add some space above the button */
        }

        .other-button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #BBBBBB;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            font-weight: bold;
        }

        .other-button:hover {
            background-color: #0056b3;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css">

    <script>
        // Wait for the DOM to be fully loaded
        document.addEventListener('DOMContentLoaded', function () {
            // Get all checkboxes with the class 'model-checkbox'
            var checkboxes = document.querySelectorAll('.model-checkbox');

            // Load the checkbox states from localStorage and apply them
            checkboxes.forEach(function (checkbox) {
                var model = checkbox.id.replace('checkbox-', '');
                var savedState = localStorage.getItem('checkbox-' + model);
                if (savedState !== null) {
                    checkbox.checked = savedState === 'true';
                    var modelElement = document.getElementById('code-' + model);
                    modelElement.style.display = checkbox.checked ? 'block' : 'none';
                }
            });



            // Add a change event listener to each checkbox
            checkboxes.forEach(function (checkbox) {
                checkbox.addEventListener('change', function () {
                    // Get the model name from the checkbox ID
                    var model = this.id.replace('checkbox-', '');

                    // Get the model element
                    var modelElement = document.getElementById('code-' + model);

                    // toggle the display of the model element
                    modelElement.style.display = this.checked ? 'block' : 'none';

                    // Save the state of all checkboxes to localStorage
                    checkboxes.forEach(function (cb) {
                        var modelId = cb.id.replace('checkbox-', '');
                        localStorage.setItem('checkbox-' + modelId, cb.checked);
                    });

                });
            });
        });
    </script>
</head>

<body>
    <h1>Problem {{ problem_idx }}</h1>


    <div class="button-container">
        {% set next_problem_idx = problem_idx + 1 %}
        <a href="{{ url_for('problem_mini', problem_idx=next_problem_idx) }}" class="other-button">Next Problem</a>

        {% set prev_problem_idx = problem_idx - 1 %}
        <a href="{{ url_for('problem_mini', problem_idx=prev_problem_idx) }}" class="other-button">Prev Problem</a>

        <form id="jumpToProblemForm" method="GET">
            <input type="number" id="problemInput" name="problem_idx" placeholder="Enter problem number" required>
            <button type="submit">Go</button>
        </form>
    </div>
    <script>
        document.getElementById('jumpToProblemForm').addEventListener('submit', function (event) {
            event.preventDefault();  // Prevent the form from submitting normally
            var problemIndex = document.getElementById('problemInput').value;
            var baseUrl = "{{ url_for('problem_mini', problem_idx=0) }}";  // Generate the base URL with a placeholder
            var newUrl = baseUrl.replace('0', problemIndex);  // Replace the placeholder with the actual index
            window.location.href = newUrl;  // Redirect to the new URL
        });
    </script>
    <br />
    <br />

    <!-- <div id="checkboxes">
        {% for model in models %}
        <input type="checkbox" class="model-checkbox" id="checkbox-{{ model }}" checked>
        <label for="checkbox-{{ model }}">{{ model }}@{{ evaluation[model]['correctness'] }}/{{
            evaluation[model]['performance'] }}</label>
        {% endfor %}
    </div> -->

    <div class="container">
        <div class="sub-container">
            <h3>{{ question['question_title'] }} || {{ question['difficulty'] }} || {{
                question['contest_date'].split('T')[0]}}</h3>

            <pre overflow="auto">
{{ question['question_content'] }}
            </pre>
        </div>

        <div class="sub-container">
            <select id="model-select" class="model-select">
                {% for model in models %}
                <option value="{{ model }}">{{ model }}@{{ evaluation[model]['correctness']
                    }}</option>
                {% endfor %}
            </select>


            <div id="all-results">

                {% for model in models %}

                <div class="model" id="code-{{ model }}" style="display: none;">
                    <h2> {{ model }}</h2>

                    <button data-model="{{ model }}" class="prev-solution">Previous</button>
                    <button data-model="{{ model }}" class="next-solution">Next</button>
                    <div class="solutions-container">
                        {% for code in data[model] %}

                        <div class="solution{% if loop.first %} active{% endif %}" id="solution-{{ loop.index }}">

                            <ul>
                                <li> solution idx -- {{ loop.index }} </li>
                                <li>correctness -- {{ code['pass1'] }}</li>
                            </ul>

                            <div>
                                <pre
                                    class="{{ 'passed' if code['pass1'] else 'failed' }}"><code class="language-python">{{ code['code'] }}</code></pre>
                            </div>
                        </div>

                        {% endfor %}
                    </div>

                </div>
                {% endfor %}
            </div>
        </div>
    </div>
    </div>





    <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
    <script>hljs.highlightAll();</script>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var allModels = document.querySelectorAll('.model');
            // console.log(allModels);

            allModels.forEach(function (model) {
                // console.log(model);
                var solutions = model.querySelectorAll('.solution');
                var totalSolutions = solutions.length;
                var currentIndex = 0;
                // console.log(totalSolutions, currentIndex);

                function updateActiveSolution(index) {
                    solutions.forEach(function (solution, i) {
                        if (i === index) {
                            solution.classList.add('active');
                        } else {
                            solution.classList.remove('active');
                        }
                    });
                }

                model.querySelector('.prev-solution').addEventListener('click', function () {
                    // console.log(currentIndex, model);
                    currentIndex = (currentIndex - 1 + totalSolutions) % totalSolutions;
                    updateActiveSolution(currentIndex);
                });

                model.querySelector('.next-solution').addEventListener('click', function () {
                    // console.log(currentIndex, model);
                    currentIndex = (currentIndex + 1) % totalSolutions;
                    updateActiveSolution(currentIndex);
                });
            });
        });
    </script>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var modelSelect = document.getElementById('model-select');
            var models = document.querySelectorAll('.model');
            modelSelect.addEventListener('change', function () {
                var selectedModel = this.value;
                models.forEach(function (model) {
                    if (model.id === 'code-' + selectedModel) {
                        model.style.display = 'block';
                    } else {
                        model.style.display = 'none';
                    }
                });

                console.log(localStorage.getItem('lcbviz-currentModel'));
                localStorage.setItem('lcbviz-currentModel', this.value);
                console.log(localStorage.getItem('lcbviz-currentModel'));

            });



            var currentModel = localStorage.getItem('lcbviz-currentModel');
            currentModel = currentModel || 'GPT-4-Turbo-2024-04-09';
            modelSelect.value = currentModel;
            localStorage.setItem('lcbviz-currentModel', currentModel);
            // Display the corresponding code element
            var codeElement = document.getElementById('code-' + currentModel);
            if (codeElement) {
                codeElement.style.display = 'block';
            }
            // Add an event listener to save the selected model to local storage when it changes

        });


    </script>

</body>

</html>