Calculate Credit Card Portfolio Metrics and Partnership Break-Even
Math & Bit ManipulationAuto-graded · 18 test casesLast updated
Computes the annual net contribution per card, overall portfolio profit, and the minimum number of new accounts needed to cover a marketing campaign.
Given the unit economics of a credit card product and the cost of an optional marketing program, calculate key annual metrics and the break-even volume required to justify the acquisition campaign.
You are given six financial inputs:
active_cards: The current size of the active cardholder portfolio.monthly_swipe_revenue: Monthly transaction revenue per card.annual_membership_fee: Annual fee billed once per card.monthly_interest_revenue: Monthly interest income earned per card.monthly_fraud_cost: Monthly fraud prevention and chargeback costs per card.campaign_cost: Total annual fixed expenditure for a proposed co-marketing partner campaign.
Calculate and return a dictionary with the following keys:
"annual_contribution_per_card": The total annual net dollar contribution of a single cardholder. This is computed as: $$\text{Annual Contribution} = 12 \times \text{swipe} + \text{annual fee} + 12 \times \text{interest} - 12 \times \text{fraud cost}$$"annual_profit": The current total annual contribution from the active card base: $$\text{Annual Profit} = \text{active_cards} \times \text{annual_contribution_per_card}$$"break_even_incremental_cardholders": The minimum integer number of new full-year cardholders needed to cover thecampaign_cost.- If
campaign_costis $0$, return $0$. - If
annual_contribution_per_cardis less than or equal to $0$ andcampaign_cost$> 0$, return $-1$ (as break-even is impossible). - Otherwise, compute $\lceil \frac{\text{campaign_cost}}{\text{annual_contribution_per_card}} \rceil$.
- If
Constraints
- $1 \le \text{active_cards} \le 10^7$
- $0 \le \text{monthly_swipe_revenue} \le 1000$
- $0 \le \text{annual_membership_fee} \le 1000$
- $0 \le \text{monthly_interest_revenue} \le 1000$
- $0 \le \text{monthly_fraud_cost} \le 1000$
- $0 \le \text{campaign_cost} \le 10^9$
- Output must be a dictionary with integer values matching the three specified keys.
Examples
Example 1
Input: calculate_campaign_profitability(500000, 2, 79, 15, 5, 25000000)
Output: {'annual_contribution_per_card': 223, 'annual_profit': 111500000, 'break_even_incremental_cardholders': 112108}
Example 2
Input: calculate_campaign_profitability(100000, 3, 50, 10, 4, 10000000)
Output: {'annual_contribution_per_card': 158, 'annual_profit': 15800000, 'break_even_incremental_cardholders': 63292}
Example 3
Input: calculate_campaign_profitability(1, 0, 0, 0, 0, 1)
Output: {'annual_contribution_per_card': 0, 'annual_profit': 0, 'break_even_incremental_cardholders': -1}
Hints
Hint 1
Annualize monthly metrics by multiplying by 12 before combining with annual terms.
Hint 2
Make sure to subtract fraud costs while adding revenue components.
Hint 3
Round up the ratio of campaign cost to contribution per card using math.ceil to find the integer break-even volume.
Worked solution
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Approach
To solve this problem, we standardise all financial line items to an annual time frame per account:
-
Annual Net Contribution Per Card:
- Swipe revenue: $12 \times \text{monthly_swipe_revenue}$
- Interest revenue: $12 \times \text{monthly_interest_revenue}$
- Membership fee: $\text{annual_membership_fee}$
- Fraud cost: $-12 \times \text{monthly_fraud_cost}$
Summing revenues and subtracting costs yields
annual_contribution_per_card. -
Total Portfolio Profit:
- Multiply
annual_contribution_per_cardbyactive_cards.
- Multiply
-
Break-Even Card Count:
- If
campaign_costis $0$, $0$ incremental cards are needed. - If
annual_contribution_per_card$\le 0$, each additional card generates zero or negative value, so it is impossible to recover a positive campaign cost. Return $-1$. - Otherwise, divide
campaign_costbyannual_contribution_per_cardand round up to the nearest integer usingmath.ceil.
- If
Complexity
- Time Complexity: $\mathcal{O}(1)$ because the calculation performs a constant number of arithmetic operations.
- Space Complexity: $\mathcal{O}(1)$ as only a fixed number of scalar values and a static dictionary are produced.
Python Reference Solution
import math
from typing import Dict
def calculate_campaign_profitability(
active_cards: int,
monthly_swipe_revenue: int,
annual_membership_fee: int,
monthly_interest_revenue: int,
monthly_fraud_cost: int,
campaign_cost: int
) -> Dict[str, int]:
annual_contribution_per_card = (
12 * monthly_swipe_revenue
+ annual_membership_fee
+ 12 * monthly_interest_revenue
- 12 * monthly_fraud_cost
)
annual_profit = active_cards * annual_contribution_per_card
if campaign_cost == 0:
break_even_incremental_cardholders = 0
elif annual_contribution_per_card <= 0:
break_even_incremental_cardholders = -1
else:
break_even_incremental_cardholders = math.ceil(campaign_cost / annual_contribution_per_card)
return {
"annual_contribution_per_card": annual_contribution_per_card,
"annual_profit": annual_profit,
"break_even_incremental_cardholders": break_even_incremental_cardholders,
}