Find the median, keep the order
A checkout preview loads one OrderDraft containing item prices, coupons and delivery options. It updates the subtotal, computes price statistics without reordering items, then compares routes without changing the canonical draft.
What needs to change
Repair median so its statistic includes every line item, including zero-priced items, and the caller still prints the prices in input order.
Reproduce
- Use go run on the three-price sample and compare the total, median and prices lines with the expected stdout.
Acceptance criteria
Your review marks · Saved in this browser. Test acceptance is tracked separately.
Notes
The OrderDraft reader and completed coupon helper in main.go are supplied. The caller prints the discounted subtotal, median and the original item order.
Supplied input is well-formed finite data: order id; prices followed by a nonempty odd number of integer prices, including any free items; coupons followed by zero or more integer discounts; route followed by its stops; branch name stop lines; end. Repeat whole blocks for multiple drafts. Prices and intermediate totals are exactly representable in the selected language; input validation is supplied outside this exercise.