Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site mhuxt.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!js2j From: js2j@mhuxt.UUCP (sonntag) Newsgroups: net.puzzle Subject: Re: Horses, Pigs, and Rabbits Message-ID: <893@mhuxt.UUCP> Date: Tue, 28-May-85 16:29:47 EDT Article-I.D.: mhuxt.893 Posted: Tue May 28 16:29:47 1985 Date-Received: Thu, 30-May-85 01:55:49 EDT References: <235@ihnet.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 36 > < down on the farm > > An old puzzle comes to mind. > A farmer goes to market, and buys 100 animals for 100 dollars. > Horses cost 10 dollars, pigs cost 3 dollars, and rabbits cost 50 cents. > How many of each animal did he buy? > During a long boring bus ride in my youth, I found a solution. > I have since found the second, and I believe there are no others. > Karl Dahlke ihnp4!ihnet!eklhad Let H,P,and R stand for the number of Horses, Pigs, and Rabbits the farmer buys. You've given us two equations in three variables, namely: 1.) H + P + R = 100 2.) 10*H + 3*P + 0.5*R=100 These can easily be reduced to one equation in two variables: 3.) P = (900/7) - (19/14)*R This ignores an important boundary condition: the number of any kind of animal may not be negative. We can write the equation for the line corresponding to 0 horses: 4.) P = (100/3) - (1/6)*R All solutions to this problem are contained in the segment of the line given by 3.) which lies below the intersection of 3.) and 4.) and which is cutoff in the other direction by the intersection of 3.) and P=0. This constrains solutions to 80<= R <=~94.7. Up till now we've ignored the constraint that the number of animals must be integers. (they don't sell half or quarter horses. (Well, they might sell quarter horses, but they'd probably count as a whole horse.)) Anyhow, one of the solutions lies right at the intersection of 3.) and 4.), and is R=80, P=20, H=0. Having found one solution, it's pretty easy to search for others, since (19/14)*(R-80) must be an integer. The only value of R between 80 and 94.7 for which that is an integer is (R-80) equals 14, or R=94, P=1, H=5. And there aren't any more solutions. -- Jeff Sonntag ihnp4!mhuxt!js2j "You can be in my dream if I can be in yours." - Dylan