Two-Year Show Profit: Renewal vs. New Launch
Math & Bit ManipulationAuto-graded · 19 test casesLast updated
Compute two-year profits for two show options, blend the new show's outcomes by success probability, and find the break-even probability.
Two-Year Show Profit: Renewal vs. New Launch
A streaming service must choose how to spend the next two years: keep an established series running, or launch a fresh one. Both options earn money and cost money every year. The fresh launch additionally burns a one-time setup cost before it airs.
Here are the fixed numbers, all monetary amounts in millions of dollars:
| Item | Established show | Fresh launch |
|---|---|---|
| Annual viewers | 5 million | 7 million if it succeeds; 4 million if it fails |
| Revenue per viewer per year | 15 | 15 |
| Fixed production cost per year | 50 | 60 |
| One-time setup cost | none | 20 |
In any scenario, the audience holds steady across both years. Revenue and production cost are each paid twice (once per year); the setup cost is paid only once. Ignore discounting, taxes, and anything not listed.
The probability that the fresh launch succeeds is an unknown input p — a number in the closed range from 0 to 1.
Write a function that returns a list of five floats, in this exact order:
- Established show, two-year profit — it does not depend on
p. - Fresh launch profit if it succeeds — setup cost subtracted once.
- Fresh launch profit if it fails — same structure, using the failure audience.
- Expected two-year profit of the fresh launch at probability
p, i.e. the probability-weighted blend of outcomes 2 and 3. - Break-even success probability — the value of
pat which the expected fresh-launch profit exactly equals the established show's profit.
Details that matter:
- Two-year revenue is (annual viewers × revenue per viewer) counted twice; two-year production cost is (annual fixed cost) counted twice.
- The expected profit is
p * success_profit + (1 - p) * failure_profit, evaluated literally even whenpfalls outside [0, 1] — do not clamp or validate it. - The break-even probability is
(established_profit - failure_profit) / (success_profit - failure_profit), computed from the four fixed numbers, so it stays the same regardless ofp. Do not round it. - Return plain floats, even for values that come out whole.
Constraints
0 <= p <= 1for meaningful inputs (the function must still evaluate the formula for any finite float).- All four fixed inputs are constant; only
pvaries between calls. - Returned list always has exactly 5 elements, in the order stated above.
- Exact float arithmetic is expected; no rounding at any step.
Examples
Example 1
Input: compare_show_profit_options(0.5)
Output: [50, 70, -20, 25, 0.7777777777777778]
Example 2
Input: compare_show_profit_options(7)
Output: [50, 70, -20, 610, 0.7777777777777778]
Example 3
Input: compare_show_profit_options(0.8)
Output: [50, 70, -20, 52, 0.7777777777777778]
Hints
Hint 1
Work out each scenario's two-year revenue and two-year cost separately, then subtract — and remember the setup cost appears exactly once, not once per year.
Hint 2
The success and failure branches share everything except the audience number, so their profits differ only through revenue.
Hint 3
The break-even probability makes expected profit equal to the established profit: solve p * success + (1 - p) * failure = established for p.
Worked solution
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Approach
Every scenario is the same shape: revenue per year minus cost per year, doubled for two years, minus the one-time setup cost where it applies.
- Established show. Per year it earns
5 * 15 = 75and costs50, so25per year; over two years that is50. No setup cost. - Fresh launch, success. Per year it earns
7 * 15 = 105and costs60, so45per year; two years give90, minus the20setup cost once, leaving70. - Fresh launch, failure. Per year it earns
4 * 15 = 60against a60cost, so0per year; two years give0, minus20, leaving-20. - Expected launch profit. Blend the two branches by the given probability:
p * 70 + (1 - p) * (-20). This is a straight linear interpolation, so it is computed literally from whatever float is passed in. - Break-even probability. Set
p * 70 + (1 - p) * (-20) = 50and solve:p = (50 - (-20)) / (70 - (-20)) = 70 / 90 ≈ 0.7778. Equivalently, interpolate from the failure branch up to the established profit, which is why the formula is(established - failure) / (success - failure).
Why it is correct
Because the two launch branches differ only in annual audience, and revenue and cost are linear in that audience with no fixed-per-viewer or tiered terms, the expected value of the launch equals the launch profit evaluated at the expected audience — and, more to the point, it is exactly the probability-weighted average of the two branch profits. The expected profit is therefore a linear function of p with slope success - failure = 90 and intercept failure = -20. Any linear function crosses the constant 50 at exactly one point, which is the quantity reported in slot 5; computing it from the fixed numbers makes it independent of the p passed in, matching the required behaviour. The setup cost is subtracted once in each branch because it is incurred before airing regardless of outcome.
Complexity
- Time: O(1) — a fixed handful of arithmetic operations.
- Space: O(1) — a single list of five floats.