Project Euler Lab - Problem 155

#155 - Counting Capacitor Circuits

● AdvancedOfficial difficulty: 45%NetworksTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

An electric circuit uses exclusively identical capacitors of the same value \(C\).
The capacitors can be connected in series or in parallel to form sub-units, which can then be connected in series or in parallel with other capacitors or other sub-units to form larger sub-units, and so on up to a final circuit.

Using this simple procedure and up to \(n\) identical capacitors, we can make circuits having a range of different total capacitances. For example, using up to \(n=3\) capacitors of \(\pu{60 \mu F}\) each, we can obtain the following \(7\) distinct total capacitance values:

If we denote by \(D(n)\) the number of distinct total capacitance values we can obtain when using up to \(n\) equal-valued capacitors and the simple procedure described above, we have: \(D(1)=1\), \(D(2)=3\), \(D(3)=7\), \(\dots\)

Find \(D(18)\).

Reminder: When connecting capacitors \(C_1, C_2\) etc in parallel, the total capacitance is \(C_T = C_1 + C_2 + \cdots\),
whereas when connecting them in series, the overall capacitance is given by: \(\dfrac{1}{C_T} = \dfrac{1}{C_1} + \dfrac{1}{C_2} + \cdots\)

This problem is taken from Project Euler, Problem 155.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=155. Published Saturday, 19th May 2007, 02:00 am. Solved by 4,250 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.