16
$\begingroup$

Jack has \$1000 and plans to buy chocolates for all that money. He finds out that his favourite chocolate sells for \$1, but there is a special offer: for every four wrappers he gives to the shopkeeper, he gets to have one additional chocolate.

How many chocolates can Jack eat with his money?

$\endgroup$
  • 3
    $\begingroup$ The puzzle leaves you with one wrapper at the end. It would have been much more interesting if it left you with $0 and 3 wrappers (or required wrappers - 1 it it wasn't 4), because you couldn't buy a chocolate with it, but you could borrow a wrapper and give it back later, or go into the shop, ask for a chocolate, say you'll pay in a minute, then unwrap it, and pay with the 4 wrappers. Result: one extra chocolate! $\endgroup$ – vsz Jul 4 '15 at 7:50
25
$\begingroup$

Certainly Jack can't eat all that chocolate in one sitting, and he'll get sick of chocolate if he binges on it for a few days. Even if he buys it all at once and rations it, it could get discolored and get a funky texture long before he gets a chance to eat it all. The store owner might not even stock more than a few dozen of his favorite chocolates at any given time. Besides, $1000 is an awful lot of cash for Jack to carry around, and if he got mugged he wouldn't be able to buy any chocolate.

So the most rational solution is...

...for him to buy and eat one chocolate per day, over the course of 1333 days.
Jack starts with \$1000 .

He buys 1 chocolate; now he has \$999 .

After this, for every 3 chocolates he buys, he gets 4.

1 chocolate + (\$999 / \$3 * 4 chocolates) = 1333 chocolates

If he puts his chocolate money in a high-yield savings account, he might even be able to buy one more chocolate on the interest he accrues during those roughly 3-1/2 years.

$\endgroup$
  • 2
    $\begingroup$ I'm having trouble with the formatting; if anyone can help me I'd appreciate it. The dollar signs were messing up my list and the algebraic expression, then I wasn't sure how to do a multi-line hidden answer. $\endgroup$ – rob Jul 3 '15 at 17:10
  • 2
    $\begingroup$ Do you have any reference on the oxydation of chocolate ? $\endgroup$ – Gabriel Romon Jul 3 '15 at 17:23
  • 3
    $\begingroup$ @LeGrandDODOM just personal experience. I've bought large amounts of chocolate before and when I didn't finish them within a year or so it ended up oxidizing and turning gross. It's possible I could have stored it differently to prevent the oxidation, and maybe some types of chocolate are more susceptible than others. $\endgroup$ – rob Jul 3 '15 at 17:26
  • 1
    $\begingroup$ Chocolate bars don't oxidize much; chocolate contains quite a lot of antioxidants that prevents this. You're referring to sugar or fat bloom, described here, which is basically just a small amount of separation when stored in too humid or warm of an environment. Not a big deal, just changes the texture slightly. $\endgroup$ – Joe Jul 3 '15 at 20:44
  • 1
    $\begingroup$ I love the fact that you imply a high-yield savings account will only give 0.1% return in 3.5 years. $\endgroup$ – Joe Z. Jul 3 '15 at 21:25
18
$\begingroup$

The answer is

1333 bars

First step

Jack buys all the choc he can afford, 1000 bars giving him 1000 wrappers

Second step:

Jack hands in those 1000 wrappers to get 250 bars and 250 wrappers

Third step:

Jack hands in 248 of the wrappers and gets 62 bars, giving him 64 wrappers

Fourth step:

Jack hands in those 64 wrappers for 16 bars and 16 wrappers

Fifth step:

Jack hands in the 16 wrappers for 4 more bars and 4 wrappers

Final step:

Jack hands in those 4 wrappers for another bar

This gives a total of:

1000 + 250 + 62 + 16 + 4 + 1 = 1333 bars

$\endgroup$
18
$\begingroup$

He can eat $1333$ chocolates. To show this mathematically without calculating each step, imagine that he starts with $4000$ wrappers instead of $\$1000$. This is, of course, equivalent. Considering that each chocolate costs $4$ wrappers and yields one, we find that the number of wrappers he has remaining after eating $c$ chocolates is: $$4000-4c+c$$ or $$4000-3c$$ So long as he has at least $4$ wrappers remaining, he can buy more chocolate - so we are looking for the first $c$ such that the above quantity is less than $4$. Solving yields: $$4000-3c<4$$ $$3996<3c$$ $$\frac{3996}3<c$$ $$1332<c$$ and the first integer satisfying this is obviously $1333$.

It is worthy of note that this equals $\lfloor\frac{4000}{3}\rfloor$, the value if each chocolate simply cost $3$ wrappers (and yielded no wrappers). However, that problem is not equivalent - consider the case where each chocolate cost $5$ wrappers, but yielded $2$ wrappers. Even though each chocolate is still a net loss $3$ wrappers, he will only be able to buy $1332$ chocolates. In the extreme case, if each chocolate cost $4001$ wrappers, but yielded $3998$ wrappers, he could buy none - hence one must use the somewhat more sophisticated approach above rather than just dividing.

$\endgroup$
  • 1
    $\begingroup$ This looks like the best solution to me, proving it without the iterative process. $\endgroup$ – Joe Jul 3 '15 at 20:48
  • $\begingroup$ floor(initial/((cost-yield)*yield))*yield. floor(4000/((4-1)*1))*1=1333. floor(4000/((5-2)*2))*2=1332. floor(4000/((4001-3998)*3998))*3998=0. $\endgroup$ – Taemyr Jul 6 '15 at 12:39
6
$\begingroup$

A slightly different proof without iteration.

The case above is equivalent to the series:

$$\lim_{k->\infty}\sum_{i=0}^k 1000\times\left(\frac{1}{4}\right)^i $$

where each 'iteration' is one set of exchanges; the first ($i=0$) is when he buys the initial thousand chocolates, and then from there on out he buys $\frac{1}{4}$ the previous iteration's amount.

That is a convergent geometric series of the form

$$\sum_{i=0}^\infty (a\times r^i) $$

where $a=1000$ and $r=\frac{1}{4}$.

That converges to

$$\frac{a}{1-r}$$

for $r<1$, which in this case means it converges to $\lfloor{1000/0.75}\rfloor$ or $1333$.

Thus, he can buy 1333 chocolates over his various iterations, with only 1 wrapper remaining at the end.

As pointed out in comments, we actually need to subtract one from the numerator for this to truly work out: while our infinite series is an accurate representation, we must have one wrapper left over at the end (the wrapper for the last chocolate we ate), which is equivalent to 0.25 dollars/chocolates. As such, the true solution is $\lfloor{\frac{1000-0.25}{0.75}}\rfloor$. This is still $1333$ in this case, of course.


Of course, this assumes he doesn't have the ability to invest his money in the market. If he invested at 10% annual return, and bought chocolates with the return, he could buy [100/.75] or 133 chocolates per year (plus an occasional bonus chocolate every four years, for leap years) indefinitely, assuming he got identical returns every year and/or conserved excesses to spend or recapitalize in down years. He'd only take about ten years to recapture his full 1333 chocolates (actually 1332, so it would be a few days into the next year) to equal his earnings if he simply ate it all now, assuming no inflation or change in store policies.

$\endgroup$
  • $\begingroup$ If $M=1000$ and $N=4$, Meelo's answer is $\lceil\frac{M(N-1)}{N-1}\rceil$ and yours is $\lfloor\frac{MN}{N-1}\rfloor$; my gut feel suggests Meelo is right. $\endgroup$ – Bravo Jul 3 '15 at 21:21
  • $\begingroup$ @Bravo I'm not sure how you work that out. That (your alleged solution for Meelo) would be solving to 1000, not to 1333. In any event, the above is very simply the mathematical expression of the sum expressed by the various iterative solutions - which are clearly correct in their own right. $\endgroup$ – Joe Jul 3 '15 at 21:23
  • 1
    $\begingroup$ Even that doesn't work though, it generates 1332, not 1333. His solution finds the lowest number that you can buy more than. It's not easily expressed the way you put it though - for example, with $M=1729$ and $N=3$, you get 2592 for his and 2593 (discarding .5) for mine - still the same solution since you have to add one in cases when it resolves to an integer for his solution (like in the $M=1000$ $N=4$ case). $\endgroup$ – Joe Jul 3 '15 at 21:38
  • 1
    $\begingroup$ Ohhh, nevermind, I see it. Because of what I posted on another answer! Because in the 'true' solution, we must have a minimum of one wrapper left over (so 1/N less than my solution): the last chocolate we bought. $\endgroup$ – Joe Jul 3 '15 at 22:19
  • 1
    $\begingroup$ @Joe That's an excellent way to see it - I just got it algebraically out of my solution, which ends as "the least integer strictly greater than $\frac{MN-N}{N-1}$" which is the floor of that plus one. $\endgroup$ – Milo Brandt Jul 3 '15 at 22:22
4
$\begingroup$

This may be solved as follows using some nice math.

A non-infinate fractional series.
1000 * (1 + 1/4 + 1/16 + 1/64 + 1/256 + 1/1024) = 1333
Each layer adds up the next iterations worth of wrappers till there is only one left.

$\endgroup$
3
$\begingroup$

You eat 1333

You start with 1000 chocolates and eat them all so you get 1000 wrappers. Then, as long as you have more than 3 wrappers you trade them for more chocolate

chocos = 1000
wrappers = chocos
while wrappers > 3:
    chocos += wrappers / 4
    wrappers = wrappers / 4 + wrappers % 4

On first iteration you get 250 additional wrappers, then 250 / 4 = 62 plus 2 leftover, then 64 / 4 = 16, then 16 / 4 = 4 and finally 4 / 4 = 1 which means you have 1000 + 250 + 62 + 16 + 4 + 1 = 1333 chocolates and no leftover wrappers.

PS: thanks luxmi12 for pointing out the 2 forgotten wrappers

$\endgroup$
  • $\begingroup$ I think you've missed a few off. Doing 250/4 = 62 plus 2 unused wrappers, which can then be used again for more chocolate (yum) $\endgroup$ – luxmi12 Jul 3 '15 at 14:37
  • $\begingroup$ you are right. I'll update the answer with the fix $\endgroup$ – Davide Jul 3 '15 at 14:39
  • $\begingroup$ I would think you always have one leftover wrapper. The last chocolate you buy... $\endgroup$ – Joe Jul 3 '15 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.