The Chocolate And Wrappers Problem

Here’s an interesting mind twister:
A chocolate costs 1 rupee each. You can also exchange 3 wrappers for a chocolate. If you have 15 rs, how many chocolates can you get??

I posted the question on my facebook wall and instantly started getting lots of answers from friends. To my surprise many of them got it wrong. I even had to explain the logic to some of them before they could understand why the answer was 22.

You can exchange the 15 wrappers for 5 chocolates. Now you have 15 chocolates without wrappers and 5 with wrappers.
Now exchange three more wrappers for a chocolate. Now you have 18 chocolates without wrappers and 2+1 chocolates with wrappers.
Again exchange the 3 wrappers for one more chocolate. Now you have 21+1=22 chocolates.

Here’s an interesting variation of the problem.
You can buy 5 chocolates for rs.4 but only one with re.1 . You have 50 bucks in your pocket.As before, you can exchange 3 wrappers for a chocolate. What is the max number of chocolates you can have and the number of wrappers you will have in the end ??

Here’s the logic leading up to the correct answer
12 bucks 22 chocolate + 1wrapper
36 bucks 67 chocolate + 1wrapper
48 bucks 89 chocolate + 2wrapper
49 bucks 91 chocolate + 1wrapper
50 bucks 92 chocolate + 2wrapper

In fact, the question can be used as a programming problem. Here’s the source code in php. Even if you don’t know php, the logic is clear enough for anyone to understand.
$chocolate = 0;
$wrapper = 0;
$money = 50;

$chocolate = 5*(int)($money/4);
$chocolate += $money%4;
$wrapper = $chocolate;
echo $chocolate;
echo $wrapper;

$temp = (int)($wrapper/3);
$wrapper = $temp + (int)($wrapper%3);
$chocolate += $temp;
echo $chocolate;

echo $wrapper;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: