Thursday, 23 October 2025

Exercise (1.4).4

A collection of bars costs £2 and a collection of rolls costs £3. List the number of bars and rolls you can purchase with £20, leaving no change. You must buy at least one of each.


We encode the scenario as follows, with $b>0$ being the number of bars, and $r>0$ the number of rolls.

$$ 2b + 3r = 20$$


The coefficients are small enough for us to find solutions by brute force, but we'll follow the procedure we'd use for larger coefficients.


Here $\gcd(2,3)=1$, which divides 20, so the equation has integer solutions.

By inspection a solution is $b_0 = 4, r_0 = 4$. A general solution is

$$ b = 4 + 3t,  r = 4 - 2t $$

for any $t$.

However, since both $b$ and $r$ must be greater than zero we have the following inequalities

$$ 4 + 3t > 0 $$

$$ 4 - 2t > 0 $$

Re-arranging

$$ t > -\frac{4}{3}  $$

$$ 2 > t $$

That is

$$ - \frac{4}{3} < t < 2$$


The only values of $t$ that lead to integer $b$ and $r$ are $t=-1, 0 and 1$. There are therefore 3 solutions:

  1. $t=-1$ gives $b=1, r = 6$, that is one bar and six rolls.
  2. $t = 0$ gives $b=4, r = 4$, that is four bars and four rolls.
  3. $t=1$ gives $b=7, r=2$, that is seven bars and two rolls.