Beginner · 25 min · 4 steps
Making a cart price calculator that does not lose money on discounts
Vikram Seth, Checkout Services Engineer at MealExpress
Vikram Seth is a checkout engineer at MealExpress, a food delivery app in North and West India. It is 7:30 PM on a Friday during the Diwali rush. The finance director has posted an urgent message in #checkout-engineering: in the last two hours the company has lost over Rs 22,00,000 to promotions.
The question
How do we build a cart price calculator that gives the same answer every time, applies discounts in a fixed order, and never sells below cost?
- Pure functions
- Discount hierarchies
- Floor bounds
- Deterministic arithmetic
The rest of this case study is locked
The data, every step with its code and result, and the final answer open with a pass. A few case studies stay free so you can see how they work.