| 404 | : res.values.every((v: any) => v != null && Math.abs(v) < 1e-6) ? { v: 'solved' } : { v: 'wrong' }; |
| 405 | const covers = (a: number[], b: number[]) => b.every((br) => a.some((ar) => Math.abs(ar - br) <= 1e-6 * (1 + Math.abs(br)))); |
| 406 | // GCD is defined up to a constant, so two gcds agree iff one is a scalar multiple |
| 407 | // of the other (constant ratio across sample points). |
| 408 | const gcdSolved = (res: any) => res && res.status === 'ok' && res.values && res.values.length >= 2 && res.values.every((v: any) => v != null && isFinite(v)); |
| 409 | const scalarMultiple = (a: number[], b: number[]) => { |
| 410 | const ratios: number[] = []; |
| 411 | for (let i = 0; i < a.length; i++) if (a[i] != null && b[i] != null && b[i] !== 0) ratios.push(a[i] / b[i]); |