Annual Profit and Break-Even Value for a Lounge Menu Item
Math & Bit ManipulationAuto-graded · 19 test casesLast updated
Compute a per-site annual operating result and the break-even per-unit benefit from visit volume, uptake rate, unit cost, unit benefit, a one-time setup cost, and a time horizon.
Menu Item Economics for One Lounge
A travel-card issuer is piloting a new made-to-order menu item in an airport lounge. For a single lounge, you know the visitor traffic, the share of visitors who order the item, what each serving costs, how much retention benefit each serving is worth, and a one-time equipment cost.
Write a function that returns two figures for one lounge:
- Annual operating profit: the yearly net result of serving the item, ignoring the one-time setup cost.
- Break-even benefit per serving: the per-serving benefit that would make total benefit over the whole horizon exactly cover both the variable costs and the one-time setup cost.
Inputs
annual_visits(int): eligible visits to the lounge per year.take_rate(float): fraction of visits that result in one serving being ordered.variable_cost_per_burger(float): cost of producing one serving.retention_value_per_burger(float): benefit credited for each serving.fixed_setup_cost(float): one-time setup cost for the lounge.horizon_years(int): number of years over which the break-even is evaluated.
Definitions
-
Servings per year =
annual_visits * take_rate(do not round; keep it as a real number). -
Annual operating profit = servings per year × (
retention_value_per_burger−variable_cost_per_burger). -
Break-even benefit per serving =
variable_cost_per_burger+fixed_setup_cost/ (servings per year ×horizon_years).This is the benefit at which total benefit across the horizon equals total variable cost plus the setup cost, assuming volume is the same each year.
Edge cases
- If servings per year is
0, orhorizon_yearsis0, the break-even value is undefined and must be returned asNone.
Output
Return a dictionary with exactly two keys:
"annual_operating_profit": afloat."break_even_retention_value_per_burger": afloat, orNonein the undefined case above.
Constraints
annual_visits >= 0,horizon_years >= 0.0 <= take_rate <= 1.- Costs and values are non-negative real numbers.
- No rounding is required; return the plain computed values.
Examples
Example 1
Input: lounge_item_economics(150000, 0.4, 4.5, 3, 120000, 2)
Output: {'annual_operating_profit': -90000, 'break_even_retention_value_per_burger': 5.5}
Example 2
Input: lounge_item_economics(100000, 0.25, 5, 8, 120000, 2)
Output: {'annual_operating_profit': 75000, 'break_even_retention_value_per_burger': 7.4}
Example 3
Input: lounge_item_economics(200000, 0.5, 3.75, 3.75, 100000, 2)
Output: {'annual_operating_profit': 0, 'break_even_retention_value_per_burger': 4.25}
Hints
Hint 1
Start by computing the number of servings per year: visits multiplied by the take rate.
Hint 2
Annual profit is servings times the per-serving margin (benefit minus variable cost); the setup cost is not part of it.
Hint 3
For break-even, spread the setup cost across all servings over the horizon and add it to the variable cost per serving. Guard against dividing by zero when there are no servings or no horizon.
Worked solution
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Approach
This is a direct application of unit economics.
-
Servings per year. Multiply visits by the take rate. Keep the result as a float, with no rounding.
-
Annual operating profit. Each serving contributes
retention_value_per_burger - variable_cost_per_burger. Multiplying by servings per year gives the annual result. The one-time setup cost is deliberately excluded here. -
Break-even benefit per serving. Over the horizon, total servings are
annual_servings * horizon_years. For total benefit to equal total cost, the benefit per servingbmust satisfy:b * N = variable_cost * N + fixed_setup_cost, whereN = annual_servings * horizon_years.Solving gives
b = variable_cost + fixed_setup_cost / N. In words: the variable cost per serving plus the setup cost spread evenly across every serving in the horizon. -
Edge case. If
Nwould be zero (no servings, or a zero-year horizon), the formula divides by zero, so the break-even is reported asNone.
Why it is correct
The break-even equation is linear in b, so it has a single solution whenever N > 0. The profit formula is simply servings times margin. Both follow directly from the definitions in the statement.
Complexity
Time: O(1). Space: O(1).
Reference solution
from typing import Dict, Optional
def lounge_item_economics(annual_visits: int, take_rate: float, variable_cost_per_burger: float, retention_value_per_burger: float, fixed_setup_cost: float, horizon_years: int) -> Dict[str, Optional[float]]:
annual_servings = annual_visits * take_rate
annual_profit = annual_servings * (retention_value_per_burger - variable_cost_per_burger)
if annual_servings == 0 or horizon_years == 0:
break_even = None
else:
break_even = variable_cost_per_burger + fixed_setup_cost / (annual_servings * horizon_years)
return {
"annual_operating_profit": float(annual_profit),
"break_even_retention_value_per_burger": None if break_even is None else float(break_even),
}