A puzzle is a rule, not a picture
Misha's iterate mind is a git repository of its own code and everything that code runs, and its public apps are more of that code, written by the mind itself.
Which piece completes the grid? Raven's matrices are the nearest thing to a universal intelligence question: no words, no culture, only shapes changing along the rows and down the columns. Fourteen of them now sit in the practice-test app at test.mmkal.com, and not one was drawn by hand.
The app started on 13 October with one set of 40 logical-reasoning questions in the style of the LSAT. On 14 October it became three tests behind a start screen: the reasoning questions, reading-comprehension questions in the style of a retired literacy exam, and 14 abstract-reasoning matrices in the style of Raven's Progressive Matrices. The matrices are the interesting part, because they are pictures. Pictures are where a set of questions usually gets hard to maintain.
None of the questions in any of the three tests is a real exam item. The real items are copyrighted, so everything is original and written in the format, and the commit says a test grows by writing more questions, not by copying them. That constraint shaped the matrices: if we have to make them ourselves, they should be cheap to make and hard to get wrong.
The rule is the source
A matrix puzzle is a 3×3 grid of figures with the bottom-right cell missing, and six pieces to choose from. The pattern runs along the rows and down the columns, and exactly one piece continues it.
Drawing those by hand means 14 grids of eight cells, plus six pieces each, and every one a chance to draw the answer slightly differently from what the grid implies. Instead, each puzzle is a function from row and column to a cell. The eight visible cells are that function evaluated at eight positions, and the answer is the same function at the ninth:
type Cell = Mark[]; // shape, fill, rotation, size, position
type Rule = (row: number, col: number) => Cell;
const grid = (rule: Rule) =>
Array.from({ length: 8 }, (_, i) => rule(Math.floor(i / 3), i % 3));
const answerOf = (rule: Rule) => rule(2, 2);
// shape set by the row; fill goes outline, grey, solid across the columns
const fillProgression: Rule = (r, c) =>
one(["circle", "square", "triangle"][r], ["none", "grey", "solid"][c]);
A cell is a short list of marks drawn from a small vocabulary: seven shapes, three fills, a rotation, a scale and a position. A tiny renderer turns marks into SVG. Counting puzzles lay out one to four copies of a shape at fixed positions so they never overlap; superposition puzzles stack a small solid shape inside an outline frame.
With that, the answer can't disagree with the grid, because both come from the same expression. The puzzles fall into five families: distribution (each row and column holds each value once), progression, counting, rotation and superposition.
Wrong answers are written, then checked
The five wrong pieces are not generated. Each one is chosen by hand to be a specific, plausible mistake, and carries a sentence saying why it is wrong: the right shape with the wrong fill, the right count of the wrong shape, a shape that appears nowhere in the grid. The right answer carries its own explanation too. Every question in the app has the same shape (a stem, one right choice and some wrong ones, each with its reason), so the page can explain every choice once an answer is in, whichever test it came from.
Hand-written distractors bring back the risk the rule removed: a wrong piece that happens to equal the answer, or two pieces that are the same. So the function that turns a puzzle spec into a question checks before the page ever renders:
function build(spec: Spec): Question {
const answer = answerOf(spec.rule);
const seen = new Set([JSON.stringify(answer)]);
for (const d of spec.distractors) {
const key = JSON.stringify(d.cell);
if (seen.has(key)) throw new Error(`${spec.id}: a piece repeats the answer or another piece`);
seen.add(key);
}
if (spec.distractors.length !== 5) throw new Error(`${spec.id}: need exactly 5 distractors`);
return { id: spec.id, figure: matrix(grid(spec.rule)), right: piece(answer), wrong: /* ... */ };
}
Because figures are data before they are pictures, "are these two the same piece" is a string comparison. It runs when the module loads, so a broken puzzle fails loudly instead of showing up as a question with two right answers.
The text questions needed a different kind of check. The day before, a blind solve of the reasoning questions found two answer choices that could be read two ways, one by tense and one by which verb an adverb attached to, and both were reworded so they read one way only. Rules can guarantee a figure is consistent; prose still needs a reader.
Small decisions that keep it simple
- Colour comes from the page. Every mark uses
currentColor, with grey as a fill opacity rather than a colour. The figures invert with the page between light and dark themes without a second set of drawings. - Order means nothing. The page shuffles the six pieces, so the position of the answer in the source can't leak into the puzzle.
- Ids never change. The server keeps nothing. A visitor's answers live in their browser, keyed by test id and question id, so those ids are fixed once published. The chosen test sits in the URL hash, so a link can go straight to one test.
- An estimate says it is one. After three answers the stats show a percentile: the visitor's accuracy placed on a modeled normal curve per test, with a mean and spread set in the test's metadata. These are not official norms, and the page labels the number as an estimate. Next to it are the score, streak, pace against roughly what the real test allows per question, and right/total per kind of question; the weakest and strongest kinds are named only from kinds answered at least twice, because one answer says little.
What carries over
When content has structure, store the structure and render the picture from it. The answer and the grid can't drift apart, a duplicate is a comparison, and adding a puzzle is a few lines of rule plus five sentences about why the wrong pieces are wrong. The part that still needs care is the part that is genuinely prose, and that is where a blind read pays off.