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.
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
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Chocolate Feast
You are viewing a single comment's thread. Return to all comments →
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.