Tom just bought 100 animals for a total of $100. The 100 animals consists of sheep, pigs and hens.

The sheep cost $10 each. The pigs cost $2 each. The hens cost 50c.

How many of each animal did he buy?
It’s not too hard to solve by trial and error, but we are looking for a logical solution so we can be sure it’s unique.

Solution over the fold.

As stated there are indeed 2 solutions: 1/27/72 and 4/8/88.

Explanation

The constraints are easily seen to be:

  • 1 <= s <= 9 (puzzle says “sheep” which could be singular or plural)
  • 2 <= p <= 45 (puzzle says “pigs” ie plural)
  • 2 <= h <= 172 (obviously h must be even)

Using the quantity information:

  • s + p + h = 100

And the price information (doubling to avoid half dollars):

  • 20s + 4p + h = 200

Subtracting:

  • 19s+3p = 100

Or:

  • p = (100 – 19s) / 3

By inspection s must be 1 or 4, and the solution follows.

Had the puzzle used a plural animal (such as cows) instead of sheep there would have been only a single solution. I would like that better.