This question is from the medieval manuscript Propositiones ad Acuendos Juvenes (Problems to Sharpen the Young).

A merchant buys $100$ pigs for $100$ dollars. A boar costs $10$ dollars, a sow costs $5$ dollars, and two piglets cost $1$ dollar. How many boars, sows, and piglets were bought? Show hint

Make variables for the number of boars, sows, and piglets.

Let $b$ be the number of boars, $s$ be the number of sows, and $p$ be the number of piglets. The fact that there are $100$ pigs gives us the equation: \[b + s + p = 100\] and their cost (remembering that it’s two piglets for a dollar) gives us: \[10b + 5s + p/2 = 100.\] At this point I’d probably multiply the last equation by $2$ to clean it up and get rid of the fraction: \[20b + 10s + p = 200.\] Now you can either subtract one equation from the other so that the $p$s cancel, or use substitution for the same effect, but in any case, eliminating the piglet term will be the neatest way (I’ll briefly cover the other ways afterwards). \[19b + 9s = 100.\] It’s easy to use trial and error at this point. Or we can reason that since $s$ is a whole number, \begin{align*} 19b &\equiv 100 \pmod{9}\\ (2\times9 + 1)b &\equiv 11\times9 + 1 \pmod{9}\\ b &\equiv 1 \pmod{9}. \end{align*} That is, $b=1,10,19,\ldots$ (we can’t have a negative number of boars). Solving for $s$, we get: \[s = \frac{100-19b}{9}\] If $b=1$, then $s=9$, and $p=90$ to make $100$ pigs. The other possible values for $b$ give negative sows, so this is the only solution.

Alternatively, you may have eliminated the sows, giving: \[-10b + 9p = 800.\] From this equation you can conclude that $p$ is divisible by $10$, or that $b\equiv 1\pmod{9}$, then you just need to try a few values to work out which solution has non-negative numbers of boars, sows, and piglets.

If you instead eliminated the $b$ term, you’d get: \[10s + 19p = 1800\] So $p$ is divisible by $10$ again, and a little trial and error will show that it must be $90$. (It’s also possible to work out that $s\equiv 9\pmod{19}$ by the method from Question 7.9.12, but it’s unnecessary and not as easy.)