Answer to May 19, 2003 Problem
from Car Talk

One Hundred Bucks of Pets

You’re given a hundred dollars and told to spend it all purchasing exactly a hundred animals at the pet store. Dogs cost $15. Cats cost a dollar, and mice are 25 cents each.
You have to purchase at least one of each animal.

The question is, how many of each animal do you have to purchase to equal one hundred animals purchased at exactly one hundred dollars?

 

Solution to Problem:

3 dogs, 41 cats and 56 mice.

Let D stand for the number of dogs, C for the number of cats, and M stand for the number of mice.

Then you can write two equations:
D + C + M = 100 and
15 D + 1 C + 0.25 M = 100.00.

It wasn't going to be five dogs because five dogs would eat up $75 and then you'd only have $25 with which to buy another 95 animals, and it wasn't going to work.

And you know it wasn't zero dogs because that was one of the conditions of the problem.

So, use trial and error with dogs = 4, then 3, 2, and 1 to see which works. The answer turns out to be 3 dogs, 41 cats and 56 mice.

Pet Number Total Cost
Dogs 3 $45.00
Cats 41 $41.00
Mice 56 $14.00

James Alarie sent in the following Javascript to solve the problem:

 for (Dogs=1; Dogs<=6; Dogs++) {
  for (Cats=1; Cats<=99; Cats++) {
   for (Mice=1; Mice<=399; Mice++) {
    Cost=1500*Dogs+100*Cats+25*Mice;
    if ((Dogs*1+Cats*1+Mice*1 == 100) && (Cost == 10000)) {
     alert(Dogs+' '+Cats+' '+Mice);
    }}}}


Correctly solved by:

1. Dave Smith Toledo, Ohio
2. William Funk San Antonio, Texas
3. Walt Arrison Philadelphia, Pennsylvania
4. Jeffrey Gaither Winchester, Virginia
5. Peggah Sadeghzadeh Winchester, Virginia
6. Richard Johnson La Jolla, California
7. Rick Jones Kennett Square, Pennsylvania
8. John Funk Ventura, California
9. Tina Zahel Winchester, Virginia
10. Misty Carlisle Winchester, Virginia
11. Jaime Garcia Winchester, Virginia
12. John Beasley Winchester, Virginia
13. David and Judy Dixon Bennettsville, South Carolina
14. Ben Reames Columbus, Georgia
15. Pam Hedrick Winchester, Virginia
16. James Alarie University of Michigan -- Flint,
Flint, Michigan
17. George Gaither Winchester, Virginia
18. Michael Rodriguez Great Falls, Montana
19. Steve Heck ----------