Two pieces of code do all the work here, and the whole point of the study is that they
must not be the same piece. Learn the checker first — in an optimize study
the checker is the load-bearing part, and Klein's METHOD gate treats it that way: the
Practice leg of the Theory + Papers + Practice triad is the from-scratch
verifier, not the searcher.
Three points with integer coordinates are collinear exactly when the cross product of the two edge vectors vanishes:
The quantity is twice the signed area of the triangle. It is an integer, so the test is exact: there is no division, no slope, no floating point and no rounding decision anywhere on the path. A configuration is valid when that expression is non-zero for every triple it contains.
The verifier is deliberately the dumbest correct implementation. It reads the artifact,
checks it is well-formed — integer coordinates (a Python bool is an
int, and is refused explicitly), on the grid, no repeats — and then walks
every triple:
for a, b, c in combinations(points, 3):
cross = (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
if cross == 0:
raise Rejected(f"points {a}, {b} and {c} are collinear")
return len(points)
No sampling, no early exit that could hide a triple, no clever geometry. On the largest object this study verified that is 26235 cross products, and the checker's own log records 0.002046 seconds for it — cheap, and the cost is charged to no guardrail.
The search may be as clever as it likes. Adding a point to a valid set can only create triples that contain , and is collinear exactly when is parallel to . So look at the world from : reduce each offset to its primitive direction and ask whether two of them collide.
That turns an question into an one — and it is not what the checker does. Two deliberately different algorithms agreeing is evidence; one algorithm agreeing with itself is a tautology.
Iterated local search over configurations that are valid at every instant: complete greedily, keep improvements, perturb, repeat.
S = [] # always a VALID configuration
while evaluations < B:
order = shuffle(all cells); order.sort(key=lambda c: rows[c.y] + cols[c.x])
for p in order: # one pass = one greedy completion
evaluations += 1 # ONE EVALUATION = one addability test
if addable(p, S): S.append(p)
if len(S) > len(best): best = S[:] # accept improvements only
elif stale >= 2n: S = [] # restart from empty
else: remove 1-3 random points from S
Two details matter. The budget unit is one call to
addable — the atomic cost of the search — and it is what the registered
guardrail caps. The ordering is most-constrained-first: a
configuration needs exactly two points in every row
and every column, so the emptiest lines are the ones still to be filled; the shuffle comes
before the sort, so ties break randomly and every pass is a fresh sample.
The whole thing is deterministic in : one random stream drives every choice and the budget only says when to stop. A larger budget is therefore a strict extension of a smaller one, which is why the ladder below is one trajectory read at three points and its objective is monotone by construction rather than by luck.
For prime , the parabola has points and no three collinear. If three were, the integer determinant above would vanish, hence vanish mod , where it factors as
— a product of units for distinct . Contradiction. That is why this object can serve as a control whose score is known before any code runs: exactly .