Sort the cart from the dearest
transcript
A shop runs a bundle offer. The cheapest item of each group is free. You choose how to group the cart.
The cart holds five, nine and three. It also holds seven and six. Each bundle has two items.
Sorted, the free items are seven and five. In cart order, they are five and three.
Sort the prices from the dearest. Take every second item in that order. Subtract them from the total.
The free item is the cheapest of its group. So never waste it on a dear item. Keep the dear items together.
Some items may not fill a bundle. They pay in full. Nothing is free for them.
In the interview, ask who chooses the groups. Ask what is free in each group. And ask what happens to items left over.
Prices are whole units. A large total uses sixty-four bits. Never use floating point for money.
Dearest items together. Every group-th item is free. Full breakdown in the lecture.