Project Euler Lab - Problem 299

#299 - Three Similar Triangles

● ResearchOfficial difficulty: 90%PointsTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

Four points with integer coordinates are selected:
\(A(a, 0)\), \(B(b, 0)\), \(C(0, c)\) and \(D(0, d)\), with \(0 \lt a \lt b\) and \(0 \lt c \lt d\).
Point \(P\), also with integer coordinates, is chosen on the line \(AC\) so that the three triangles \(ABP\), \(CDP\) and \(BDP\) are all similarHave equal angles.

0299_ThreeSimTri.gif

It is easy to prove that the three triangles can be similar, only if \(a = c\).

So, given that \(a = c\), we are looking for triplets \((a, b, d)\) such that at least one point \(P\) (with integer coordinates) exists on \(AC\), making the three triangles \(ABP\), \(CDP\) and \(BDP\) all similar.

For example, if \((a, b, d)=(2,3,4)\), it can be easily verified that point \(P(1,1)\) satisfies the above condition. Note that the triplets \((2,3,4)\) and \((2,4,3)\) are considered as distinct, although point \(P(1,1)\) is common for both.

If \(b + d \lt 100\), there are \(92\) distinct triplets \((a, b, d)\) such that point \(P\) exists.
If \(b + d \lt 100\,000\), there are \(320471\) distinct triplets \((a, b, d)\) such that point \(P\) exists.

If \(b + d \lt 100\,000\,000\), how many distinct triplets \((a, b, d)\) are there such that point \(P\) exists?

This problem is taken from Project Euler, Problem 299.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=299. Published Saturday, 3rd July 2010, 01:00 am. Solved by 753 members at time of mirroring.

Why this is useful

Optimization. The transferable skill is replacing infeasible enumeration with a mathematical reduction - the core move in calibration and large-scale computation (Phases 10, 13).

We classify relevance honestly - not every Euler problem is a trading application.

Learning mode

Pick how much scaffolding you want. Your choice is remembered per problem.

Scratchpad

Mathematical notes, formulas, pseudocode, hypotheses, complexity notes. Saved automatically with your progress.

Python workbench

Tier C - reduced scale in browser; full scale in notebook
Browser runs a reduced, clearly-labelled educational scale; the original scale is provided in a local notebook.

Real Python (Pyodide) in a sandboxed Web Worker - no network, no filesystem, no DOM access. Ctrl/Cmd+Enter runs. Escape leaves the editor. Stop terminates the worker.

Python runtime not loaded (it boots on first run - a one-time local load).

Check your answer

Answers are checked against a salted hash held in a separate file - not printed in this page. This prevents accidental spoilers; it is not cryptographic protection (see the build notes).

Progressive hints

Confidence

Low confidence schedules this problem for spaced review, even if you solved it.

Reference solution

Spoiler
The complete original explanation (interpretation, naive approach, insight, proof, complexity, Python implementation, tests, common mistakes, alternatives) is hidden and lazy-loaded. Reveal it only after a meaningful attempt - the struggle is where the learning happens.