Project Euler Lab - Problem 529

#529 - $10$-substrings

● ResearchOfficial difficulty: 98%Naive enumeration is infeasible; requires a mathematical reductionTier D - conceptual / notebook executionNot viewed
↖ Euler Lab

A \(10\)-substring of a number is a substring of its digits that sum to \(10\). For example, the \(10\)-substrings of the number \(3523014\) are:

  • 3523014
  • 3523014
  • 3523014
  • 3523014

A number is called \(10\)-substring-friendly if every one of its digits belongs to a \(10\)-substring. For example, \(3523014\) is \(10\)-substring-friendly, but \(28546\) is not.

Let \(T(n)\) be the number of \(10\)-substring-friendly numbers from \(1\) to \(10^n\) (inclusive).
For example \(T(2) = 9\) and \(T(5) = 3492\).

Find \(T(10^{18}) \bmod 1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 529.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=529. Published Saturday, 10th October 2015, 10:00 pm. Solved by 318 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.

Prerequisites

Lessons that prepare you:
19.14 Computational Complexity, Feasibility Estimation, and Proving Algorithms Correct · 19.7 Dynamic Programming: Memoization and Tabulation

Recommended stepping-stone problems: #891 · #354 · #821

Concepts: brute-force-reduction

Likely techniques: digit-dp

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 D - conceptual / notebook execution
Too heavy for browser Pyodide at original scale: the browser is used for planning, small cases and reasoning; full scale runs 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.