Farmer buys livestock puzzle

Published by Fudgy McFarlen on

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.

[pmath] 10x+5y+0.5z=100  [/pmath]

[pmath] x+y+z=100  [/pmath]

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

[pmath] 20x+10y+z=200  [/pmath]

[pmath] x+y+z=100  [/pmath]

yields

[pmath] 19x+9y=100  [/pmath]  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:  [pmath] x+y+z=100  [/pmath]  now plug in number until you get an even z. Try x=1:

[pmath] 19+9y=100  [/pmath]

[pmath] 9y=81  [/pmath]

[pmath] y=9  [/pmath]

[pmath] 1+9+z=100  [/pmath]

[pmath] z=90  [/pmath]

and is even and thus the problem is done

 

Modulus Solution

[pmath] 19x+9y=100  [/pmath]

[pmath] (19x+9y)mod 9 = 100 mod 9 [/pmath]

[pmath] (19x) mod 9 + (9y) mod 9 = 1 [/pmath]

[pmath] (19x) mod 9  = 1 [/pmath]

[pmath] (19 mod 9)  *( x mod 9)  = 1 [/pmath]

[pmath]  ( x )mod 9 = 1 [/pmath]

Two obvious solutions are 

[pmath]  x=1  [/pmath]  and [pmath]  x=10  [/pmath]  

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 *

Rich Text Editor, comment