Project Euler Lab - Problem 883

#883 - Remarkable Triangles

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

In this problem we consider triangles drawn on a hexagonal lattice, where each lattice point in the plane has six neighbouring points equally spaced around it, all distance \(1\) away.

We call a triangle remarkable if

  • All three vertices and its incentre lie on lattice points
  • At least one of its angles is \(60^\circ\)
0883_diagram.png

Above are four examples of remarkable triangles, with \(60^\circ\) angles illustrated in red. Triangles A and B have inradius \(1\); C has inradius \(\sqrt{3}\); D has inradius \(2\).

Define \(T(r)\) to be the number of remarkable triangles with inradius \(\le r\). Rotations and reflections, such as triangles A and B above, are counted separately; however direct translations are not. That is, the same triangle drawn in different positions of the lattice is only counted once.

You are given \(T(0.5)=2\), \(T(2)=44\), and \(T(10)=1302\).

Find \(T(10^6)\).

This problem is taken from Project Euler, Problem 883.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=883. Published Sunday, 24th March 2024, 04:00 am. Solved by 123 members at time of mirroring.

Why this is useful

Algorithmic Development. Graph/state-space search transfers to routing, dependency resolution, and execution-path optimisation (Phases 16, 17).

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.