A farmer has 100 dollars to buy 100 animals.  A cow costs 10, a pig costs 5 and a chicken costs 50 cents.  How many of each does he buy?  He must use all his money and he must buy at least 1 of each type.

10x+5y+0.5z=100 

x+y+z=100 

note Z must be even because otherwise you will get  ddd.5<> 100 in the first equation. Eliminate z by multiplying first equation by 2 and subtracting the second equation

20x+10y+z=200 

x+y+z=100 

yields

19x+9y=100   Here a solution is only found because the solution is specified to be integers

 

Brute force Integer solution

Find a solution for the above and plugging into:  x+y+z=100   now plug in number until you get an even z. Try x=1:

19+9y=100 

9y=81 

y=9 

1+9+z=100 

z=90 

and is even and thus the problem is done

 

Modulus Solution

19x+9y=100 

(19x+9y)mod 9 = 100 mod 9

(19x) mod 9 + (9y) mod 9 = 1 

(19x) mod 9  = 1 

(19 mod 9)  *( x mod 9)  = 1 

 ( x )mod 9 = 1 

Two obvious solutions are 

 x=1    and  x=10    

The first solution is viable.  The second is not because there is no money left over to buy any other type of animal.

Categories: MathPuzzles

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *