In a pet shop, rats cost $5$ dollars each, guppies cost $3$ dollars each, and crickets cost $10 $ cents each. $100$ animals are sold, and the total cost is $100$. How many rats, guppies, and crickets were sold?

Our math team coach has shown us the solution already, but her solution requires $7$ different variables and takes at least $10$ minutes for me to solve. The math team contest has $6$ diophantine equations problems of increasing difficulty. I only have $40$ minutes to complete these $6$ questions and I am not allowed to use a calculator.

What is the fastest or simplest way to solve this problem without a calculator?


1 Answer 1



$$50r + 30g + c = 1000\tag{1}$$ $$r+g+c = 100\tag{2}$$

Eliminating one variable gives you a linear diophantine equation in two variables whose solution is straightforward. $$49r + 29g = 900 \tag{3}$$

Another approach which works well for this specific problem is :

$$r = \dfrac{900 - 29g}{7\times 7}$$

Since $900$ leaves a remainder of $4$ when divided by $7$,
$29g$ must also leave the remainder $4$ for $r$ to be an integer : $$29g \equiv 4 \pmod 7 \implies g \equiv 4 \pmod 7 $$

Plugging in $g=4$ gives you $r=16$. This is one solution.

  • $\begingroup$ Sorry, I don't really understand still. I got 49r+29g=900 and solving for r gets me r=(900-29g)/49. Where do I go from here? $\endgroup$
    – Alzeon
    Sep 21, 2014 at 22:46
  • $\begingroup$ The goal here is to find a positive integer solution for $r$ and $g$. One way is to use the standard method for solving linear diophantine equations. Familiar with euclidean algorithm for finding gcd ? $\endgroup$
    – AgentS
    Sep 21, 2014 at 22:50
  • $\begingroup$ @Alzeon - I have updated the answer with a simpler method that doesn't use euclid algorithm. Check it out :) $\endgroup$
    – AgentS
    Sep 21, 2014 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .