Which streaming plan is worth the ad budget?
A streaming service in Toronto sells several plans. Finance wants the customer lifetime value over a fixed horizon, with churn and discounting, and the month in which each plan pays back its acquisition cost.
Task: line 1 is the horizon H in months. Line 2 is the monthly discount rate d in percent (decimal). Line 3 is the number of plans n. Then n lines name price margin churn cac: monthly price, gross margin in percent, monthly churn in percent, and acquisition cost per customer (all numbers, name has no spaces). For months t = 1..H the discounted contribution of one acquired customer is price * margin/100 * (1 - churn/100)^(t-1) / (1 + d/100)^t. The clv is the sum over the horizon, and net = clv - cac. The payback month is the first t where the running sum of contributions reaches cac or more, or never if that does not happen within the horizon. Print one line per plan, sorted by net descending (ties by name ascending), as name clv=A net=B payback=P with A and B to 2 decimals.
Sample tests
Input
24 1 3 Basic 9.99 70 6 35 Standard 15.49 72 4 45 Premium 22.99 75 3 120
Expected output
Premium clv=267.63 net=147.63 payback=9 Standard clv=157.11 net=112.11 payback=5 Basic clv=82.08 net=47.08 payback=7
Input
12 0 2 Trial 5 50 10 40 Gold 30 80 2 20
Expected output
Gold clv=258.34 net=238.34 payback=1 Trial clv=17.94 net=-22.06 payback=never
Your answer is also checked against 3 hidden tests.
Need a hint?
Loop month by month so that the running sum gives both the CLV and the payback month in one pass.
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
