Project Euler Lab - Problem 126

#126 - Cuboid Layers

● AppliedOfficial difficulty: 29%PointsTier B - browser, with the efficient algorithmNot viewed
↖ Euler Lab

The minimum number of cubes to cover every visible face on a cuboid measuring \(3 \times 2 \times 1\) is twenty-two.


If we then add a second layer to this solid it would require forty-six cubes to cover every visible face, the third layer would require seventy-eight cubes, and the fourth layer would require one-hundred and eighteen cubes to cover every visible face.

However, the first layer on a cuboid measuring \(5 \times 1 \times 1\) also requires twenty-two cubes; similarly the first layer on cuboids measuring \(5 \times 3 \times 1\), \(7 \times 2 \times 1\), and \(11 \times 1 \times 1\) all contain forty-six cubes.

We shall define \(C(n)\) to represent the number of cuboids that contain \(n\) cubes in one of its layers. So \(C(22) = 2\), \(C(46) = 4\), \(C(78) = 5\), and \(C(118) = 8\).

It turns out that \(154\) is the least value of \(n\) for which \(C(n) = 10\).

Find the least value of \(n\) for which \(C(n) = 1000\).

This problem is taken from Project Euler, Problem 126.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=126. Published Friday, 18th August 2006, 06:00 pm. Solved by 5,648 members at time of mirroring.

Why this is useful

General Problem Solving. Builds computational thinking, decomposition, and debugging discipline - transferable, without a specific financial application.

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

Prerequisites

Lessons that prepare you:
19.10 Search: Backtracking, Branch-and-Bound, Binary Search, Meet-in-the-Middle · 3.1 Vectors, Multivariable Functions, and Level Sets

Recommended stepping-stone problems: #577 · #349 · #745

Concepts: geometry

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 B - browser, with the efficient algorithm
Runs in the browser only with the intended efficient algorithm; a naive loop will hit the timeout.

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.