Quant Memo
Coding/●●●●●

Enumerate every subset of a set of positions

Given a set of distinct positions, produce every subset (the power set), including the empty set and the full set. For a scenario sweep you might want to price every possible sub-portfolio.

items = ["A", "B"]
-> [[], ["A"], ["A", "B"], ["B"]]

Return all 2^n subsets. The order of subsets does not matter, but each should appear exactly once.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions