We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

I'm confused... The sample states that we get chocolates per trip, and that means we get wrappers per trip. However, this also means that we get an extra chocolates per trip, right?

Given 10 dollars with chocolates for 2 dollars each, you can get 5 chocolates. That's 5 wrappers. To get a free chocolate, you need 5 wrappers, which we have, so now we have 6 chocolates. This means we now have 1 extra wrapper (total: 6, extra: 1)

Next, we have 12 dollars with chocolates for 4 dollars each. That means we can purchase 3 chocolates, meaning we now have 3 wrappers, plus the extra 1 from the last purchase. We need 4 wrappers to get a free chocolate, which we have, so we get a free chocolate and consequently have 1 extra wrapper (total: 4, extra: 1)

Finally, we have 6 dollars to spend on chocolates for 2 dollars each. This means we can buy 3 chocolates, giving us 3 new wrappers, plus the extra 1 from the last purchase. We need 2 wrappers to obtain a free chocolate, and we actually have 4 wrappers, meaning we get 2 free chocolates and 2 more wrappers as a consequence. We can obtain 1 chocolate more for free as a result, leading to 1 final chocolate and 1 extra wrapper (total: 6, extra: 1)

So how is the sample output 6, 3, 5 when we can clearly obtain 6, 4, 6?

The way it works is the number of leftover wrappers doesn't carry over to the next trip to the store, meaning once you can no longer trade for a free chocolate, any extra wrappers you have are no longer able to be traded.

You purchase 5 chocolates, meaning you have 5 wrappers. You trade the 5 wrappers for 1 free chocolate for a total of 6 chocolates. The wrapper for the 1 free chocolate is the only wrapper left. Because you have 1 wrapper, not 5, you cannot receive any more chocolate, so the remaining wrapper is discarded. Chocolates=5+1=6, extra=1

You purchase 3 chocolates, meaning you have 3 wrappers. However, 4 wrappers are needed to trade for 1 free chocolate, so you cannot receive any chocolates. Those 3 wrappers are discarded. Chocolates=3, extra=3

You purchase 3 chocolates, meaning you have 3 wrappers. 2 wrappers are needed to receive a free chocolate, so you trade in 2/3 of your wrappers for 1 free chocolate. This leaves you with 1 wrapper from the chocolate you paid for and 1 wrapper from the 1 free chocolate, or 2 wrappers total. You trade them both for 1 more chocolate, leaving you with 1 wrapper to be discarded. Chocolates=3+1+1=5, extra=1

## Chocolate Feast

You are viewing a single comment's thread. Return to all comments →

I'm confused... The sample states that we get chocolates per trip, and that means we get wrappers per trip. However, this also means that we get an extra chocolates per trip, right?

Given 10 dollars with chocolates for 2 dollars each, you can get 5 chocolates. That's 5 wrappers. To get a free chocolate, you need 5 wrappers, which we have, so now we have 6 chocolates. This means we now have 1 extra wrapper (total: 6, extra: 1)

Next, we have 12 dollars with chocolates for 4 dollars each. That means we can purchase 3 chocolates, meaning we now have 3 wrappers, plus the extra 1 from the last purchase. We need 4 wrappers to get a free chocolate, which we have, so we get a free chocolate and consequently have 1 extra wrapper (total: 4, extra: 1)

Finally, we have 6 dollars to spend on chocolates for 2 dollars each. This means we can buy 3 chocolates, giving us 3 new wrappers, plus the extra 1 from the last purchase. We need 2 wrappers to obtain a free chocolate, and we actually have 4 wrappers, meaning we get 2 free chocolates and 2 more wrappers as a consequence. We can obtain 1 chocolate more for free as a result, leading to 1 final chocolate and 1 extra wrapper (total: 6, extra: 1)

So how is the sample output 6, 3, 5 when we can clearly obtain 6, 4, 6?

What am I missing?

I am having the same issue, not sure when the extra wrappers count and when they don't.

The way it works is the number of leftover wrappers doesn't carry over to the next trip to the store, meaning once you can no longer trade for a free chocolate, any extra wrappers you have are no longer able to be traded.