Project Euler Lab - Problem 553

#553 - Power Sets of Power Sets

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

Let \(P(n)\) be the set of the first \(n\) positive integers \(\{1, 2, \dots, n\}\).
Let \(Q(n)\) be the set of all the non-empty subsets of \(P(n)\).
Let \(R(n)\) be the set of all the non-empty subsets of \(Q(n)\).

An element \(X \in R(n)\) is a non-empty subset of \(Q(n)\), so it is itself a set.
From \(X\) we can construct a graph as follows:

  • Each element \(Y \in X\) corresponds to a vertex and labeled with \(Y\);
  • Two vertices \(Y_1\) and \(Y_2\) are connected if \(Y_1 \cap Y_2 \ne \emptyset\).

For example, \(X = \{\{1\},\{1,2,3\},\{3\},\{5,6\},\{6,7\}\}\) results in the following graph:

0553-power-sets.gif

This graph has two connected components.

Let \(C(n, k)\) be the number of elements of \(R(n)\) that have exactly \(k\) connected components in their graph.
You are given \(C(2, 1) = 6\), \(C(3, 1) = 111\), \(C(4, 2) = 486\), \(C(100, 10) \bmod 1\,000\,000\,007 = 728209718\).

Find \(C(10^4, 10) \bmod 1\,000\,000\,007\).

This problem is taken from Project Euler, Problem 553.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=553. Published Saturday, 26th March 2016, 10:00 pm. Solved by 269 members at time of mirroring.

Why this is useful

Algorithmic Development. Optimal substructure and state-space reasoning are exactly how American-option pricing and optimal execution are solved (Phases 13, 16).

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.