eklhad@ihnet.UUCP (K. A. Dahlke) (05/28/85)
< 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. Diophantus experts have a real advantage here. By the way, does anyone have any programs for solving such problems? I am too lazy (and have no real need) to write any, but they might be fun to play with. -- Karl Dahlke ihnp4!ihnet!eklhad
js2j@mhuxt.UUCP (sonntag) (05/28/85)
> < 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
jlc@afinitc.UUCP (Gerald Collins) (05/30/85)
[] > < 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? > Karl Dahlke ihnp4!ihnet!eklhad These statements work out to the equations: 10H + 3P + .5R = 100 and H + P + R = 100 a little shuffling gives 6P + R = 200 - 20H P + R = 100 - H subtracting gives: 5P = 100 - 19H divide by five gives: P = 20 - 19H/5 Therefore the only solutions possible are where H is divisible by 5. If H = 10 or any number > 10 then P is negative which is impossible. Therefore H = 0, P = 20, R = 80, and H = 5, P = 1, R = 94 are the only solutions possible.
arash@jendeh.UUCP (Arash Farmanfarmaian) (05/31/85)
> < 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. > Diophantus experts have a real advantage here. > By the way, does anyone have any programs for solving such problems? > I am too lazy (and have no real need) to write any, > but they might be fun to play with. > -- > > Karl Dahlke ihnp4!ihnet!eklhad Since when one needs to be a diaphantine expert to solve such problems? Especially since Diaphantine problems accept rational solutions (ever tried to buy a rational number of rabits?). I would have thought you would need modular arithmetic, as developped by Fermat, to solve this kind of problem. Arash Farmanfarmaian'85 -- Arash Farmanfarmaian ...!allegra!princeton!jendeh!arash "Any man who lives within his means suffers from a lack of imagination"