Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +423 -19
- prompts.txt +5 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
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: equationgen
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: blue
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,423 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Linear Equation Generator with Integer Solutions</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.equation {
|
11 |
+
font-family: 'Times New Roman', Times, serif;
|
12 |
+
font-size: 1.5rem;
|
13 |
+
}
|
14 |
+
.hint {
|
15 |
+
transition: all 0.3s ease;
|
16 |
+
max-height: 0;
|
17 |
+
overflow: hidden;
|
18 |
+
}
|
19 |
+
.hint.active {
|
20 |
+
max-height: 200px;
|
21 |
+
padding: 0.5rem 0;
|
22 |
+
}
|
23 |
+
input:focus + .hint-container .hint {
|
24 |
+
max-height: 200px;
|
25 |
+
}
|
26 |
+
.fade-in {
|
27 |
+
animation: fadeIn 0.3s ease-in-out;
|
28 |
+
}
|
29 |
+
@keyframes fadeIn {
|
30 |
+
from { opacity: 0; transform: translateY(10px); }
|
31 |
+
to { opacity: 1; transform: translateY(0); }
|
32 |
+
}
|
33 |
+
</style>
|
34 |
+
</head>
|
35 |
+
<body class="bg-gray-100 min-h-screen">
|
36 |
+
<div class="container mx-auto px-4 py-12 max-w-3xl">
|
37 |
+
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
|
38 |
+
<div class="p-8">
|
39 |
+
<h1 class="text-3xl font-bold text-center text-indigo-700 mb-2">
|
40 |
+
<i class="fas fa-square-root-alt mr-2"></i>Linear Equation Generator
|
41 |
+
</h1>
|
42 |
+
<p class="text-gray-600 text-center mb-8">Practice solving linear equations with integer solutions</p>
|
43 |
+
|
44 |
+
<div class="flex flex-col md:flex-row gap-6 mb-8">
|
45 |
+
<div class="flex-1 bg-indigo-50 p-6 rounded-lg">
|
46 |
+
<h2 class="text-xl font-semibold text-indigo-800 mb-4">
|
47 |
+
<i class="fas fa-sliders-h mr-2"></i>Settings
|
48 |
+
</h2>
|
49 |
+
|
50 |
+
<div class="space-y-4">
|
51 |
+
<div>
|
52 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Difficulty</label>
|
53 |
+
<select id="difficulty" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
|
54 |
+
<option value="easy">Easy (one-step)</option>
|
55 |
+
<option value="medium">Medium (two-step)</option>
|
56 |
+
<option value="hard">Hard (multi-step)</option>
|
57 |
+
<option value="parentheses" selected>With Parentheses</option>
|
58 |
+
</select>
|
59 |
+
</div>
|
60 |
+
|
61 |
+
<div>
|
62 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Variable</label>
|
63 |
+
<input type="text" id="variable" value="x" maxlength="1" class="w-16 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 text-center">
|
64 |
+
</div>
|
65 |
+
|
66 |
+
<div>
|
67 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Number Range</label>
|
68 |
+
<div class="flex items-center gap-2">
|
69 |
+
<input type="number" id="minNum" value="-10" class="w-20 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
|
70 |
+
<span>to</span>
|
71 |
+
<input type="number" id="maxNum" value="10" class="w-20 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500">
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
+
|
76 |
+
<button id="generateBtn" class="mt-6 w-full bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-4 rounded-md transition duration-150 ease-in-out transform hover:scale-105">
|
77 |
+
<i class="fas fa-random mr-2"></i>Generate Equation
|
78 |
+
</button>
|
79 |
+
</div>
|
80 |
+
|
81 |
+
<div class="flex-1 bg-white p-6 rounded-lg border border-gray-200">
|
82 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">
|
83 |
+
<i class="fas fa-question-circle mr-2"></i>Problem
|
84 |
+
</h2>
|
85 |
+
|
86 |
+
<div id="equationContainer" class="equation bg-gray-50 p-4 rounded-lg mb-4 text-center min-h-16 flex items-center justify-center">
|
87 |
+
<p class="text-gray-500">Click "Generate Equation" to start</p>
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<div class="mt-6">
|
91 |
+
<label for="userAnswer" class="block text-sm font-medium text-gray-700 mb-1">Your Answer</label>
|
92 |
+
<div class="relative">
|
93 |
+
<input type="text" id="userAnswer" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 pr-10" placeholder="Enter the value of x">
|
94 |
+
<div class="hint-container absolute right-3 top-1/2 transform -translate-y-1/2">
|
95 |
+
<i class="fas fa-lightbulb text-yellow-500 cursor-pointer hint-icon"></i>
|
96 |
+
<div class="hint absolute right-0 mt-2 w-64 bg-yellow-50 text-yellow-800 text-sm p-2 rounded-md shadow-lg z-10">
|
97 |
+
Enter the numerical value only (e.g. 5 or -3)
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
|
103 |
+
<button id="checkBtn" class="mt-4 w-full bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-md transition duration-150 ease-in-out">
|
104 |
+
<i class="fas fa-check mr-2"></i>Check Answer
|
105 |
+
</button>
|
106 |
+
|
107 |
+
<div id="feedback" class="mt-4 p-3 rounded-md hidden"></div>
|
108 |
+
|
109 |
+
<button id="showStepsBtn" class="mt-2 w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-md transition duration-150 ease-in-out hidden">
|
110 |
+
<i class="fas fa-list-ol mr-2"></i>Show Solution Steps
|
111 |
+
</button>
|
112 |
+
|
113 |
+
<div id="solutionSteps" class="mt-4 hidden bg-blue-50 p-4 rounded-md text-sm space-y-2"></div>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
|
117 |
+
<div class="bg-gray-50 p-6 rounded-lg">
|
118 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">
|
119 |
+
<i class="fas fa-history mr-2"></i>Recent Problems
|
120 |
+
</h2>
|
121 |
+
<div id="history" class="space-y-2">
|
122 |
+
<!-- History items will be added here -->
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
</div>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
|
129 |
+
<script>
|
130 |
+
document.addEventListener('DOMContentLoaded', function() {
|
131 |
+
// DOM elements
|
132 |
+
const generateBtn = document.getElementById('generateBtn');
|
133 |
+
const checkBtn = document.getElementById('checkBtn');
|
134 |
+
const equationContainer = document.getElementById('equationContainer');
|
135 |
+
const userAnswer = document.getElementById('userAnswer');
|
136 |
+
const feedback = document.getElementById('feedback');
|
137 |
+
const history = document.getElementById('history');
|
138 |
+
const difficulty = document.getElementById('difficulty');
|
139 |
+
const variable = document.getElementById('variable');
|
140 |
+
const minNum = document.getElementById('minNum');
|
141 |
+
const maxNum = document.getElementById('maxNum');
|
142 |
+
const showStepsBtn = document.getElementById('showStepsBtn');
|
143 |
+
const solutionSteps = document.getElementById('solutionSteps');
|
144 |
+
|
145 |
+
// Current equation data
|
146 |
+
let currentEquation = null;
|
147 |
+
let currentSolution = null;
|
148 |
+
let currentSteps = [];
|
149 |
+
|
150 |
+
// Generate a random integer between min and max
|
151 |
+
function randomInt(min, max) {
|
152 |
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
153 |
+
}
|
154 |
+
|
155 |
+
// Generate a non-zero random integer between min and max
|
156 |
+
function randomNonZero(min, max) {
|
157 |
+
let num = 0;
|
158 |
+
while (num === 0) {
|
159 |
+
num = randomInt(min, max);
|
160 |
+
}
|
161 |
+
return num;
|
162 |
+
}
|
163 |
+
|
164 |
+
// Generate a linear equation with integer solution
|
165 |
+
function generateEquation() {
|
166 |
+
const varSymbol = variable.value || 'x';
|
167 |
+
const min = parseInt(minNum.value) || -10;
|
168 |
+
const max = parseInt(maxNum.value) || 10;
|
169 |
+
const diff = difficulty.value;
|
170 |
+
|
171 |
+
// First generate a random integer solution
|
172 |
+
const solution = randomInt(min, max);
|
173 |
+
|
174 |
+
let equation = '';
|
175 |
+
let steps = [];
|
176 |
+
|
177 |
+
if (diff === 'easy') {
|
178 |
+
// ax = b format where b is divisible by a
|
179 |
+
const a = randomNonZero(min, max);
|
180 |
+
const b = a * solution;
|
181 |
+
|
182 |
+
equation = `${a}${varSymbol} = ${b}`;
|
183 |
+
|
184 |
+
steps = [
|
185 |
+
`Given equation: ${equation}`,
|
186 |
+
`Divide both sides by ${a}: ${varSymbol} = ${b}/${a}`,
|
187 |
+
`Solution: ${varSymbol} = ${solution}`
|
188 |
+
];
|
189 |
+
}
|
190 |
+
else if (diff === 'medium') {
|
191 |
+
// ax + b = c format where (c - b) is divisible by a
|
192 |
+
const a = randomNonZero(min, max);
|
193 |
+
const b = randomInt(min, max);
|
194 |
+
const c = a * solution + b;
|
195 |
+
|
196 |
+
equation = `${a}${varSymbol} ${b < 0 ? '-' : '+'} ${Math.abs(b)} = ${c}`;
|
197 |
+
|
198 |
+
steps = [
|
199 |
+
`Given equation: ${equation}`,
|
200 |
+
`Subtract ${b} from both sides: ${a}${varSymbol} = ${c - b}`,
|
201 |
+
`Divide both sides by ${a}: ${varSymbol} = ${solution}`,
|
202 |
+
`Solution: ${varSymbol} = ${solution}`
|
203 |
+
];
|
204 |
+
}
|
205 |
+
else if (diff === 'hard') {
|
206 |
+
// ax + b = cx + d format where (d - b) is divisible by (a - c)
|
207 |
+
const a = randomNonZero(min, max);
|
208 |
+
const c = randomNonZero(min, max);
|
209 |
+
|
210 |
+
// Ensure a ≠ c
|
211 |
+
while (a === c) {
|
212 |
+
c = randomNonZero(min, max);
|
213 |
+
}
|
214 |
+
|
215 |
+
const b = randomInt(min, max);
|
216 |
+
const d = (a - c) * solution + b;
|
217 |
+
|
218 |
+
equation = `${a}${varSymbol} ${b < 0 ? '-' : '+'} ${Math.abs(b)} = ${c}${varSymbol} ${d < 0 ? '-' : '+'} ${Math.abs(d)}`;
|
219 |
+
|
220 |
+
steps = [
|
221 |
+
`Given equation: ${equation}`,
|
222 |
+
`Subtract ${c}${varSymbol} from both sides: ${(a - c)}${varSymbol} ${b < 0 ? '-' : '+'} ${Math.abs(b)} = ${d}`,
|
223 |
+
`Subtract ${b} from both sides: ${(a - c)}${varSymbol} = ${d - b}`,
|
224 |
+
`Divide both sides by ${a - c}: ${varSymbol} = ${solution}`,
|
225 |
+
`Solution: ${varSymbol} = ${solution}`
|
226 |
+
];
|
227 |
+
}
|
228 |
+
else if (diff === 'parentheses') {
|
229 |
+
// Randomly choose between different formats with parentheses
|
230 |
+
const format = randomInt(1, 3);
|
231 |
+
|
232 |
+
if (format === 1) {
|
233 |
+
// a(bx + c) = d where d is divisible by a and (d/a - c) is divisible by b
|
234 |
+
const a = randomNonZero(min, max);
|
235 |
+
const b = randomNonZero(min, max);
|
236 |
+
const c = randomInt(min, max);
|
237 |
+
const d = a * (b * solution + c);
|
238 |
+
|
239 |
+
equation = `${a}(${b}${varSymbol} ${c < 0 ? '-' : '+'} ${Math.abs(c)}) = ${d}`;
|
240 |
+
|
241 |
+
steps = [
|
242 |
+
`Given equation: ${equation}`,
|
243 |
+
`Divide both sides by ${a}: ${b}${varSymbol} ${c < 0 ? '-' : '+'} ${Math.abs(c)} = ${b * solution + c}`,
|
244 |
+
`${c < 0 ? 'Add' : 'Subtract'} ${Math.abs(c)} to both sides: ${b}${varSymbol} = ${b * solution}`,
|
245 |
+
`Divide both sides by ${b}: ${varSymbol} = ${solution}`,
|
246 |
+
`Solution: ${varSymbol} = ${solution}`
|
247 |
+
];
|
248 |
+
}
|
249 |
+
else if (format === 2) {
|
250 |
+
// a(bx + c) + d = e where (e - d) is divisible by a and ((e - d)/a - c) is divisible by b
|
251 |
+
const a = randomNonZero(min, max);
|
252 |
+
const b = randomNonZero(min, max);
|
253 |
+
const c = randomInt(min, max);
|
254 |
+
const d = randomInt(min, max);
|
255 |
+
const e = a * (b * solution + c) + d;
|
256 |
+
|
257 |
+
equation = `${a}(${b}${varSymbol} ${c < 0 ? '-' : '+'} ${Math.abs(c)}) ${d < 0 ? '-' : '+'} ${Math.abs(d)} = ${e}`;
|
258 |
+
|
259 |
+
steps = [
|
260 |
+
`Given equation: ${equation}`,
|
261 |
+
`${d < 0 ? 'Add' : 'Subtract'} ${Math.abs(d)} to both sides: ${a}(${b}${varSymbol} ${c < 0 ? '-' : '+'} ${Math.abs(c)}) = ${a * (b * solution + c)}`,
|
262 |
+
`Divide both sides by ${a}: ${b}${varSymbol} ${c < 0 ? '-' : '+'} ${Math.abs(c)} = ${b * solution + c}`,
|
263 |
+
`${c < 0 ? 'Add' : 'Subtract'} ${Math.abs(c)} to both sides: ${b}${varSymbol} = ${b * solution}`,
|
264 |
+
`Divide both sides by ${b}: ${varSymbol} = ${solution}`,
|
265 |
+
`Solution: ${varSymbol} = ${solution}`
|
266 |
+
];
|
267 |
+
}
|
268 |
+
else {
|
269 |
+
// a(bx + c) = d(ex + f) where (a*c - d*f) is divisible by (d*e - a*b)
|
270 |
+
const a = randomNonZero(min, max);
|
271 |
+
const b = randomNonZero(min, max);
|
272 |
+
const c = randomInt(min, max);
|
273 |
+
const d = randomNonZero(min, max);
|
274 |
+
const e = randomNonZero(min, max);
|
275 |
+
const f = randomInt(min, max);
|
276 |
+
|
277 |
+
// Calculate to ensure solution is integer
|
278 |
+
const numerator = a * c - d * f;
|
279 |
+
const denominator = d * e - a * b;
|
280 |
+
|
281 |
+
// Ensure denominator is not zero and divides numerator
|
282 |
+
while (denominator === 0 || numerator % denominator !== 0) {
|
283 |
+
b = randomNonZero(min, max);
|
284 |
+
e = randomNonZero(min, max);
|
285 |
+
denominator = d * e - a * b;
|
286 |
+
}
|
287 |
+
|
288 |
+
equation = `${a}(${b}${varSymbol} ${c < 0 ? '-' : '+'} ${Math.abs(c)}) = ${d}(${e}${varSymbol} ${f < 0 ? '-' : '+'} ${Math.abs(f)})`;
|
289 |
+
|
290 |
+
steps = [
|
291 |
+
`Given equation: ${equation}`,
|
292 |
+
`Expand left side: ${a*b}${varSymbol} ${a*c < 0 ? '-' : '+'} ${Math.abs(a*c)} = ${d*e}${varSymbol} ${d*f < 0 ? '-' : '+'} ${Math.abs(d*f)}`,
|
293 |
+
`Bring all terms to one side: ${(a*b - d*e)}${varSymbol} = ${d*f - a*c}`,
|
294 |
+
`Divide both sides by ${a*b - d*e}: ${varSymbol} = ${solution}`,
|
295 |
+
`Solution: ${varSymbol} = ${solution}`
|
296 |
+
];
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
return { equation, solution, steps };
|
301 |
+
}
|
302 |
+
|
303 |
+
// Generate a new equation
|
304 |
+
generateBtn.addEventListener('click', function() {
|
305 |
+
const result = generateEquation();
|
306 |
+
currentEquation = result.equation;
|
307 |
+
currentSolution = result.solution;
|
308 |
+
currentSteps = result.steps;
|
309 |
+
|
310 |
+
equationContainer.innerHTML = `<span class="equation">${currentEquation}</span>`;
|
311 |
+
userAnswer.value = '';
|
312 |
+
feedback.classList.add('hidden');
|
313 |
+
solutionSteps.classList.add('hidden');
|
314 |
+
showStepsBtn.classList.add('hidden');
|
315 |
+
|
316 |
+
// Focus on answer input
|
317 |
+
setTimeout(() => userAnswer.focus(), 100);
|
318 |
+
});
|
319 |
+
|
320 |
+
// Check the user's answer
|
321 |
+
checkBtn.addEventListener('click', function() {
|
322 |
+
if (!currentEquation) {
|
323 |
+
feedback.textContent = 'Please generate an equation first!';
|
324 |
+
feedback.className = 'mt-4 p-3 rounded-md bg-red-100 text-red-800';
|
325 |
+
feedback.classList.remove('hidden');
|
326 |
+
return;
|
327 |
+
}
|
328 |
+
|
329 |
+
const userValue = parseFloat(userAnswer.value);
|
330 |
+
if (isNaN(userValue)) {
|
331 |
+
feedback.textContent = 'Please enter a valid number!';
|
332 |
+
feedback.className = 'mt-4 p-3 rounded-md bg-red-100 text-red-800';
|
333 |
+
feedback.classList.remove('hidden');
|
334 |
+
return;
|
335 |
+
}
|
336 |
+
|
337 |
+
// Compare with exact integer value
|
338 |
+
if (userValue === currentSolution) {
|
339 |
+
feedback.textContent = 'Correct! Well done!';
|
340 |
+
feedback.className = 'mt-4 p-3 rounded-md bg-green-100 text-green-800';
|
341 |
+
|
342 |
+
// Show steps button
|
343 |
+
showStepsBtn.classList.remove('hidden');
|
344 |
+
|
345 |
+
// Add to history
|
346 |
+
const historyItem = document.createElement('div');
|
347 |
+
historyItem.className = 'bg-white p-3 rounded-md border border-gray-200 flex justify-between items-center fade-in';
|
348 |
+
historyItem.innerHTML = `
|
349 |
+
<div>
|
350 |
+
<span class="equation">${currentEquation}</span>
|
351 |
+
<span class="text-gray-500 mx-2">→</span>
|
352 |
+
<span>${variable.value || 'x'} = ${currentSolution}</span>
|
353 |
+
</div>
|
354 |
+
<span class="text-green-500"><i class="fas fa-check-circle"></i></span>
|
355 |
+
`;
|
356 |
+
history.prepend(historyItem);
|
357 |
+
|
358 |
+
// Limit history to 5 items
|
359 |
+
if (history.children.length > 5) {
|
360 |
+
history.removeChild(history.lastChild);
|
361 |
+
}
|
362 |
+
} else {
|
363 |
+
feedback.textContent = `Not quite right. Try again! (Hint: the solution is an integer)`;
|
364 |
+
feedback.className = 'mt-4 p-3 rounded-md bg-red-100 text-red-800';
|
365 |
+
showStepsBtn.classList.remove('hidden');
|
366 |
+
}
|
367 |
+
|
368 |
+
feedback.classList.remove('hidden');
|
369 |
+
});
|
370 |
+
|
371 |
+
// Show solution steps
|
372 |
+
showStepsBtn.addEventListener('click', function() {
|
373 |
+
if (solutionSteps.classList.contains('hidden')) {
|
374 |
+
solutionSteps.innerHTML = currentSteps.map(step =>
|
375 |
+
`<div class="p-2 bg-white rounded border-b border-gray-100">${step}</div>`
|
376 |
+
).join('');
|
377 |
+
solutionSteps.classList.remove('hidden');
|
378 |
+
this.innerHTML = `<i class="fas fa-eye-slash mr-2"></i>Hide Solution Steps`;
|
379 |
+
} else {
|
380 |
+
solutionSteps.classList.add('hidden');
|
381 |
+
this.innerHTML = `<i class="fas fa-list-ol mr-2"></i>Show Solution Steps`;
|
382 |
+
}
|
383 |
+
});
|
384 |
+
|
385 |
+
// Allow pressing Enter to check answer
|
386 |
+
userAnswer.addEventListener('keypress', function(e) {
|
387 |
+
if (e.key === 'Enter') {
|
388 |
+
checkBtn.click();
|
389 |
+
}
|
390 |
+
});
|
391 |
+
|
392 |
+
// Show hint when focusing on input
|
393 |
+
const hintIcon = document.querySelector('.hint-icon');
|
394 |
+
const hint = document.querySelector('.hint');
|
395 |
+
|
396 |
+
userAnswer.addEventListener('focus', function() {
|
397 |
+
hint.classList.add('active');
|
398 |
+
});
|
399 |
+
|
400 |
+
userAnswer.addEventListener('blur', function() {
|
401 |
+
setTimeout(() => {
|
402 |
+
if (document.activeElement !== hintIcon) {
|
403 |
+
hint.classList.remove('active');
|
404 |
+
}
|
405 |
+
}, 100);
|
406 |
+
});
|
407 |
+
|
408 |
+
hintIcon.addEventListener('mouseenter', function() {
|
409 |
+
hint.classList.add('active');
|
410 |
+
});
|
411 |
+
|
412 |
+
hintIcon.addEventListener('mouseleave', function() {
|
413 |
+
if (document.activeElement !== userAnswer) {
|
414 |
+
hint.classList.remove('active');
|
415 |
+
}
|
416 |
+
});
|
417 |
+
|
418 |
+
// Generate first equation on load
|
419 |
+
generateBtn.click();
|
420 |
+
});
|
421 |
+
</script>
|
422 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ffonavia/equationgen" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
423 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
приложение для запомининия таблицы умножения, чтобы ребенку было весело
|
2 |
+
когда начинаешь ввод, появляется подсказка, и ввод невозможен, исправь это
|
3 |
+
генератор примеров линейных уравнений
|
4 |
+
добавь примеры с раскрытием скобок. корни всех примеров должны быть целыми числами
|
5 |
+
все ответы во всех уравнениях должны быть целыми числами,
|