Is the Festival Pitch Worth It?

break-even · fixed cost · contribution margin · entry decision · integer arithmetic

A crêpe cart is offered a pitch at a summer festival. The pitch costs a fixed fee fixed (paid once, however many crêpes are sold). Each crêpe sells for price and its batter, filling and paper cost unit_cost. All amounts are whole numbers of cents.

Selling q crêpes earns the profit

\pi(q) = \text{price} \cdot q - \text{unit\_cost} \cdot q - \text{fixed}

Write pitch(fixed, price, unit_cost, expected) that returns a tuple (units, profit, decision):

  1. units: the break-even output, the smallest whole number of crêpes q with \pi(q) \ge 0; None if no number of crêpes ever breaks even;
  2. profit: the profit \pi(\text{expected}) in cents if the cart sells the expected number of crêpes (negative for a loss);
  3. decision: "enter" if that profit is at least 0 (breaking exactly even counts as worth it), else "stay out".

Examples

Input:  fixed = 45000, price = 650, unit_cost = 275, expected = 150
Output: (120, 11250, 'enter')
Explanation: each crêpe leaves 650 - 275 = 375 cents towards the fee; 45000 / 375 = 120 crêpes.
Selling 150 gives 150 * 375 - 45000 = 11250 cents of profit.

Input:  fixed = 30000, price = 500, unit_cost = 320, expected = 160
Output: (167, -1200, 'stay out')
Explanation: 30000 / 180 = 166.7, so 166 crêpes still lose money and 167 is the first that does not.

Input:  fixed = 2000, price = 300, unit_cost = 300, expected = 500
Output: (None, -2000, 'stay out')

Goals

  • Find the break-even output: the fewest units whose margins cover the fixed cost
  • Round a division up to a whole number of units
  • Decide on entry from the profit at the expected sales, with the tie stated
Starting Python…