Project Euler Lab - Problem 780

#780 - Toriangulations

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

For positive real numbers \(a,b\), an \(a\times b\) torus is a rectangle of width \(a\) and height \(b\), with left and right sides identified, as well as top and bottom sides identified. In other words, when tracing a path on the rectangle, reaching an edge results in "wrapping round" to the corresponding point on the opposite edge.

A tiling of a torus is a way to dissect it into equilateral triangles of edge length 1. For example, the following three diagrams illustrate respectively a \(1\times \frac{\sqrt{3}}{2}\) torus with two triangles, a \(\sqrt{3}\times 1\) torus with four triangles, and an approximately \(2.8432\times 2.1322\) torus with fourteen triangles:

Two tilings of an \(a\times b\) torus are called equivalent if it is possible to obtain one from the other by continuously moving all triangles so that no gaps appear and no triangles overlap at any stage during the movement. For example, the animation below shows an equivalence between two tilings:

Let \(F(n)\) be the total number of non-equivalent tilings of all possible tori with exactly \(n\) triangles. For example, \(F(6)=8\), with the eight non-equivalent tilings with six triangles listed below:

Let \(G(N)=\sum_{n=1}^N F(n)\). You are given that \(G(6)=14\), \(G(100)=8090\), and \(G(10^5)\equiv 645124048 \pmod{1\,000\,000\,007}\).

Find \(G(10^9)\). Give your answer modulo \(1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 780.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=780. Published Saturday, 8th January 2022, 04:00 pm. Solved by 161 members at time of mirroring.

Why this is useful

Numerical Computing. Precision, conditioning, and numerical iteration transfer directly to pricing engines and model calibration (Phases 5, 13, 15).

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.