Message Boards Message Boards

0
|
4590 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Please show me the best way to set this out in Mathematica

Posted 9 years ago

A farmer buys 100 animals for $100.00. The animals include at least one cow, one pig, and one chicken, but no other kind. If a cow costs $10.00, a pig costs $3.00, and a chicken costs $0.50, how many of each did he buy? Please show me the best way to set this out in Mathematica

POSTED BY: Owen Parker
2 Replies

That's the only solution.

Reduce[{10 x + 3 y + z/2 == 100, x + y + z == 100, x >= 1, 
  y >= 1, z >= 1}, {x, y, z}, Integers]

x == 5 && y == 1 && z == 94

POSTED BY: Frank Kampas
Posted 9 years ago

Here is one solution: The farmer should buy 5 cows, 1 pig and 94 chickens.

In one line Mathematica code.

FindInstance[{10 x+3 y+.5 z==100,x+y+z==100,x>= 1,y>= 1,z>=1},{x,y,z},Integers]
POSTED BY: Frederick Wu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract