# Math can be sweet

I come to you with a simple problem which hopefully any of you can solve it. Although the final solution is what certifies that the problem has been solved correctly I am more interested to see the approach that each of you will consider.

## The problem

4 kids went to the shop to buy some sweets. A chocolate costs 4$, they had to pay 1$ for 4 bottle of coke. A "jelly mice" costs 0.5$. They buy chocolates, some bottles of coke and also some sweet jelly mice which they costed a total of 80$. Later they split all the sweets in 4 bags such that each bag contained exactly the same thing. Note that each bag contained 20 items in total.
The question is : what contained a bag?

## My solution

I see the problem like an system of equation. The variable are the number of chocolates (x), the number of coke bottles (y) and of course the number of jelly mice (z) that they bought in total.

What we know so far is:

\$

If we divide by what could mean the dollar symbol (we assume that the dollar symbol is just a number) the equation above will be expressed only in terms of number of items and not in terms of dollars anymore:

(E1)

We also know that each of the four bags has 20 items and all bags contains exactly the same items so we know that in total they are 4 x 20 =80 items.

Also:

(E2)

From E1 and E2 we can create a system of two equations with three unknown variables:

In theory such a system will give us an infinite number of solutions but let's narrow little bit the spectrum of possibilities.

We know that we cannot buy just a bottle of coke, we have to buy at least 4 of them. Furthermore we still know that we will buy 80 items in total where at least 4 must be coke's bottles, at least one must be chocolate and at least one should be a jelly mouse. What all these mean?

• 1 â‰¤ x â‰¤ 80-4-1 <=> 1 â‰¤ x â‰¤ 75
• 4 â‰¤ y â‰¤ 80-1-1 <=> 4 â‰¤ y â‰¤ 78
• 1 â‰¤ z â‰¤ 80 -4 -1 <=> 1 â‰¤ z â‰¤ 75

Furthermore x,y and z must be whole numbers (integers) because we cannot buy 0.1234 chocolate or 3.33333 bottle of coke, the are sold only as whole items. With these hypotheses in mind let's try to solve our system of equation. Not less important is the fact that the y (number of bottles of coke) must be multiple of 4 (because we can buy only 4x cokes).

In the equation (E1) we are going to multiply the both sides by 4 so that the equation (E1) will become:

In the equation (E2) we are going to multiply the both sides by -1 so that the equation (E2) will become:

If we add the (E1) with (E2) we'll get the following new equation:

<=> (E3)

Let z=a âˆˆ â„•.

We will express x, y and z in terms of a. From (E3) above we can solve .

If we replace the x and z in the equation E2 we'll get y in terms of a:

<=>

Because x âˆˆ â„• it means that also must be an whole number, also a is multiple of 15. So z=a can be only 15,30,45 or 60 because 1 â‰¤ z â‰¤ 75, right?

What we know so far:

and a={15; 30; 45; 60}

We'll probe each a value at a time.

When a=15 => x=15 and y=50 which doesn't divide by 4 so a=15 does not meet our criteria.

When a=30 => x=14 and y=36 which is divisible by 4 so a=30 could be one solution for our problem. Note that z=a=30.

When a=45 => x=13 and y=22 which is not divisible by 4 so a=45 does not meet our criteria.

When a=60 => x=12 and y=8 which is divisible by 4 so a=60 could be one solution for our problem. Note that z=a=60.

One bag can contain either:

• 14 chocolates, 36 bottle of coke and 30 jelly mice

or

• 12 chocolates, 8 bottles of coke and 60 jelly mice

What would be the answer? Well, keep in mind that all these must be divided equally in four bags so we have to be able to divide exactly 14 by 4, 36 by 4 and 30 by 4. The same stands for 12, 8 and 60. In the first case we see that that's not possible whether in the second case 4 divides exactly the 12,8 and 60. So we can draw the conclusion that in total they bought 12 chocolates, 8 bottle of coke and 60 jelly mice and thus one bag must contain 3 chocolates, 2 bottle of coke and 15 jelly mice.

Is it true that sometimes (if not always) math can be sweet?

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.

#### Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.