MathsReadCompetitive mathematics
Algorithmic puzzle · integer answermedium50 min

Collinear grid triples

Lattice Geometry

Consider the 13x13 array of integer lattice points (x,y) with 0<=x,y<=12. How many unordered sets of THREE distinct points are collinear? Horizontal, vertical, and diagonal lines all count.

Solve using mathematics, algorithms, or your own code offline. Submit only the final integer here—no program, expression, graph, or written proof.

Check your answer without signing in. Sign in to save your progress.

Accepted format: a whole number such as 42 or 123456789. No commas, formulas, or source code.

How to approach this problem

Group points on each geometric line using a primitive direction and a normalized line invariant. A line containing k grid points contributes k choose 3 unordered triples. Count each line exactly once.

Worked example with different values

Four points on one horizontal grid line give 4 choose 3 = 4 triples. Counting pairs of endpoints without deduplication would overcount.

Apply the same reasoning to the challenge. This example is a separate practice problem.

Learn the technique: Number theory: divisors, gcd and modular arithmetic

Report a question or explanation issue

Back to problems →