-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
373 lines (359 loc) · 6.73 KB
/
Copy pathscript.js
File metadata and controls
373 lines (359 loc) · 6.73 KB
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
const questionBank=[
{
q:"Prime factorisation of 24?",
correct:"2³ × 3",
wrong:["2² × 3","2⁴ × 3","2³ × 6"],
hint:"24 = 8 × 3"
},
{
q:"Prime factorisation of 30?",
correct:"2 × 3 × 5",
wrong:["2² × 3 × 5","3 × 5","2 × 15"],
hint:"30 is even"
},
{
q:"Prime factorisation of 36?",
correct:"2² × 3²",
wrong:["2 × 3²","2² × 3","6²"],
hint:"36 = 6 × 6"
},
{
q:"Prime factorisation of 40?",
correct:"2³ × 5",
wrong:["2² × 5","2⁴ × 5","2³ × 10"],
hint:"40 = 8 × 5"
},
{
q:"Prime factorisation of 50?",
correct:"2 × 5²",
wrong:["2² × 5","5³","10²"],
hint:"50 = 2 × 25"
},
{
q:"Prime factorisation of 54?",
correct:"2 × 3³",
wrong:["2² × 3³","2 × 3²","3⁴"],
hint:"54 = 2 × 27"
},
{
q:"Prime factorisation of 63?",
correct:"3² × 7",
wrong:["3 × 7","3³ × 7","9 × 7²"],
hint:"63 = 9 × 7"
},
{
q:"Prime factorisation of 64?",
correct:"2⁶",
wrong:["2⁵","2⁷","4⁶"],
hint:"Power of 2"
},
{
q:"Prime factorisation of 75?",
correct:"3 × 5²",
wrong:["3² × 5","5³","15 × 5"],
hint:"75 = 3 × 25"
},
{
q:"Prime factorisation of 81?",
correct:"3⁴",
wrong:["3³","3⁵","9³"],
hint:"81 = 9 × 9"
},
{
q:"Prime factorisation of 90?",
correct:"2 × 3² × 5",
wrong:["2² × 3² × 5","3² × 5","2 × 3 × 5"],
hint:"90 = 9 × 10"
},
{
q:"Prime factorisation of 98?",
correct:"2 × 7²",
wrong:["2² × 7","7³","14²"],
hint:"98 = 2 × 49"
},
{
q:"Prime factorisation of 108?",
correct:"2² × 3³",
wrong:["2³ × 3²","2² × 3²","4 × 27"],
hint:"108 = 4 × 27"
},
{
q:"Prime factorisation of 125?",
correct:"5³",
wrong:["5²","5⁴","25²"],
hint:"125 = 5 × 25"
},
{
q:"Prime factorisation of 144?",
correct:"2⁴ × 3²",
wrong:["2³ × 3²","2⁴ × 3","12²"],
hint:"144 = 16 × 9"
},
{
q:"LCM of 4 and 6?",
correct:"12",
wrong:["6","24","18"],
hint:"Use highest powers"
},
{
q:"LCM of 6 and 8?",
correct:"24",
wrong:["12","48","16"],
hint:"Find first common multiple"
},
{
q:"LCM of 5 and 7?",
correct:"35",
wrong:["12","49","70"],
hint:"Both are prime"
},
{
q:"LCM of 10 and 15?",
correct:"30",
wrong:["15","45","60"],
hint:"Use highest powers"
},
{
q:"LCM of 12 and 16?",
correct:"48",
wrong:["24","96","32"],
hint:"Prime factorise both"
},
{
q:"LCM of 14 and 21?",
correct:"42",
wrong:["21","84","28"],
hint:"Look for common factors"
},
{
q:"LCM of 15 and 25?",
correct:"75",
wrong:["50","25","100"],
hint:"Use highest powers"
},
{
q:"LCM of 16 and 20?",
correct:"80",
wrong:["40","160","60"],
hint:"Use prime factors"
},
{
q:"LCM of 18 and 24?",
correct:"72",
wrong:["36","48","96"],
hint:"Highest powers"
},
{
q:"LCM of 20 and 30?",
correct:"60",
wrong:["30","90","120"],
hint:"Common multiple"
},
{
q:"LCM of 21 and 28?",
correct:"84",
wrong:["42","168","56"],
hint:"Prime factorise"
},
{
q:"LCM of 24 and 36?",
correct:"72",
wrong:["36","108","144"],
hint:"Use highest powers"
},
{
q:"LCM of 25 and 30?",
correct:"150",
wrong:["75","300","100"],
hint:"25 = 5²"
},
{
q:"LCM of 27 and 36?",
correct:"108",
wrong:["54","216","72"],
hint:"Highest powers"
},
{
q:"LCM of 32 and 48?",
correct:"96",
wrong:["48","192","64"],
hint:"2 powers"
},
{
q:"GCD of 12 and 18?",
correct:"6",
wrong:["3","12","18"],
hint:"Common factors"
},
{
q:"GCD of 15 and 20?",
correct:"5",
wrong:["10","15","20"],
hint:"List factors"
},
{
q:"GCD of 24 and 36?",
correct:"12",
wrong:["6","24","18"],
hint:"Use lowest powers"
},
{
q:"GCD of 30 and 45?",
correct:"15",
wrong:["5","30","45"],
hint:"Both divisible by 15"
},
{
q:"GCD of 40 and 60?",
correct:"20",
wrong:["10","40","30"],
hint:"Common factors"
},
{
q:"GCD of 42 and 56?",
correct:"14",
wrong:["7","28","21"],
hint:"Prime factors"
},
{
q:"GCD of 48 and 72?",
correct:"24",
wrong:["12","36","48"],
hint:"Use lowest powers"
},
{
q:"GCD of 50 and 75?",
correct:"25",
wrong:["5","50","15"],
hint:"Common factor"
},
{
q:"GCD of 54 and 81?",
correct:"27",
wrong:["9","18","54"],
hint:"Both divisible by 27"
},
{
q:"GCD of 63 and 84?",
correct:"21",
wrong:["7","42","28"],
hint:"Lowest powers"
},
{
q:"GCD of 64 and 96?",
correct:"32",
wrong:["16","48","64"],
hint:"Powers of 2"
},
{
q:"GCD of 72 and 108?",
correct:"36",
wrong:["18","72","54"],
hint:"Common factors"
},
{
q:"GCD of 75 and 100?",
correct:"25",
wrong:["5","50","75"],
hint:"25 works"
},
{
q:"GCD of 81 and 108?",
correct:"27",
wrong:["9","54","81"],
hint:"3 powers"
},
{
q:"GCD of 90 and 135?",
correct:"45",
wrong:["15","30","90"],
hint:"Common factors"
},
{
q:"What does GCD stand for?",
correct:"Greatest Common Divisor",
wrong:["Greatest Common Difference","General Common Divisor","Great Divisor"],
hint:"Largest shared factor"
},
{
q:"What does LCM stand for?",
correct:"Least Common Multiple",
wrong:["Largest Common Multiple","Lowest Common Factor","Least Common Factor"],
hint:"Smallest shared multiple"
},
{
q:"LCM uses...",
correct:"Highest powers",
wrong:["Lowest powers","No powers","Division"],
hint:"Think multiples"
},
{
q:"GCD uses...",
correct:"Lowest powers",
wrong:["Highest powers","No powers","Subtraction"],
hint:"Think common factors"
},
{
q:"Euclidean Algorithm finds...",
correct:"GCD",
wrong:["LCM","Prime Factors","Multiples"],
hint:"Greatest common divisor"
},
{
q:"The Euclidean algorithm can use...",
correct:"Division",
wrong:["Fractions","Decimals","Percentages"],
hint:"Faster than subtraction"
}
];
let xp=0, hearts=5, streak=0, asked=0;
let current=null;
function shuffle(arr){
return [...arr].sort(()=>Math.random()-0.5);
}
function randomQuestion(){
return questionBank[Math.floor(Math.random()*questionBank.length)];
}
document.getElementById("hint").textContent="";
hintBtn.onclick=()=>hint.textContent=current.hint;
function loadQuestion(){
current=randomQuestion();
document.getElementById("question").textContent=current.q;
const answers=shuffle([current.correct,...current.wrong]);
const area=document.getElementById("answers");
area.innerHTML="";
answers.forEach(answer=>{
const btn=document.createElement("button");
btn.textContent=answer;
btn.onclick=()=>select(answer);
area.appendChild(btn);
});
document.getElementById("progressFill").style.width=((asked%20)/20*100)+"%";
}
function select(answer){
if(answer===current.correct){
xp+=10;
streak++;
asked++;
document.getElementById("feedback").textContent="✅ Correct!";
}else{
hearts--;
streak=0;
document.getElementById("feedback").textContent="❌ Incorrect";
}
document.getElementById("xp").textContent=xp;
document.getElementById("streak").textContent=streak;
document.getElementById("hearts").textContent=hearts;
if(hearts<=0){
document.querySelector(".card").innerHTML=`
<h2>💀 Game Over</h2>
<p>Final XP: ${xp}</p>
<button onclick="location.reload()">Play Again</button>`;
return;
}
setTimeout(()=>{
document.getElementById("feedback").textContent="";
loadQuestion();
},700);
}
loadQuestion();