/** * Random practice-problem generator. * * Problems are built BACKWARD from a chosen integer answer: pick the solution * first, then assemble an equation around it. This guarantees the problem is * solvable, the answer is clean, and difficulty is exactly the templates and * coefficient ranges we draw from. Every problem returns its solution(s) so a * practice loop can check the learner and serve the next one. * * The engine stays pure: randomness is an injected `Rng` (a `() => number` in * [0, 1)), never ambient `Math.random`. Callers pass `Math.random` (or a seeded * PRNG in tests). * * Single-variable topics go through `generateProblem`; two-variable systems * (two equations) go through `generateSystem`. */ import { type Equation } from "./expr.js"; import { Rational } from "./rational.js"; export type Difficulty = "easy" | "medium" | "hard"; export type ProblemTopic = "linear-one-step" | "linear-two-step" | "linear-both-sides" | "distribution" | "fractions" | "power" | "inequality" | "quadratic"; export interface ProblemSpec { readonly topic: ProblemTopic; readonly difficulty: Difficulty; } export interface GeneratedProblem { readonly equation: Equation; /** Value(s) of the variable that solve it — two for a distinct-root * quadratic; for an inequality, a witness point inside the solution set. */ readonly solutions: readonly Rational[]; readonly topic: ProblemTopic; readonly difficulty: Difficulty; } export interface SystemProblem { readonly equations: readonly [Equation, Equation]; readonly x: Rational; readonly y: Rational; readonly difficulty: Difficulty; } /** Uniform random in [0, 1) — inject `Math.random` or a seeded PRNG. */ export type Rng = () => number; /** Topics with display labels, for building a picker. */ export declare const PROBLEM_TOPICS: readonly { readonly id: ProblemTopic; readonly label: string; }[]; export declare const DIFFICULTIES: readonly Difficulty[]; /** * Generate a random single-variable problem. The equation is guaranteed * well-formed and solvable, with `solutions` its exact answer(s) (a witness * point for inequalities). `rng` supplies randomness — `Math.random` in the * app, a seeded PRNG in tests. */ export declare function generateProblem(spec: ProblemSpec, rng: Rng): GeneratedProblem; /** * Generate a random 2×2 linear system with a unique integer solution (x, y). * The coefficient matrix is non-singular by construction, so it solves by * substitution or elimination. */ export declare function generateSystem(difficulty: Difficulty, rng: Rng): SystemProblem; //# sourceMappingURL=generate.d.ts.map