Brute-force the integer solutions of a two-unknown equation over a box, as a * lexicographically sorted array — the oracle the symbolic path must match.
( f: (x: number, y: number) => number, xlo: number, xhi: number, ylo: number, yhi: number )
| 28 | /** Brute-force the integer solutions of a two-unknown equation over a box, as a |
| 29 | * lexicographically sorted array — the oracle the symbolic path must match. */ |
| 30 | function bruteForce( |
| 31 | f: (x: number, y: number) => number, |
| 32 | xlo: number, |
| 33 | xhi: number, |
| 34 | ylo: number, |
| 35 | yhi: number |
| 36 | ): number[][] { |
| 37 | const out: number[][] = []; |
| 38 | for (let x = xlo; x <= xhi; x++) |
| 39 | for (let y = ylo; y <= yhi; y++) |
| 40 | if (f(x, y) === 0) out.push([x, y]); |
| 41 | out.sort((a, b) => a[0] - b[0] || a[1] - b[1]); |
| 42 | return out; |
| 43 | } |
| 44 | |
| 45 | describe('DIOPHANTINE — linear, bounded domains', () => { |
| 46 | test('3x + 4y = 7 over [-10,10]² yields the exact lattice line', () => { |
no test coverage detected