# Sunday Times Teaser 2960 – Bags of Sweets!

### by Angela Newing

#### Published June 16 2019 (link)

I recently bought a number of equally priced bags of sweets for a bargain price, spending more than 50p in total. If they had been priced at 9p less per bag, I could have had 2 bags more for the same sum of money. In addition, if each had cost 12p less than I paid, then I could also have had an exact number of bags for the same sum of money.

How much did I spend in total on the sweets?

Let the total cost of the sweets be $$c$$ pence for $$n$$ bags at $$p$$ pence, $$n + 2$$ bags at $$p – 9$$ pence and $$m$$ bags at $$p – 12$$ pence. Hence:$c=n p=(n + 2)(p – 9)=m(p-12)$Eliminating $$c$$ gives:$\begin{eqnarray}p\;=\;9(n+2)/2\; =\;12m/(m-n)\end{eqnarray}$Now eliminating $$p$$ and arranging the result gives:$(3m – 10)^2-(6n-3m+6)^2=64$Denoting the squared terms as $$v$$ and $$w$$ we have $v^2 – w^2 = (v – w)(v + w) = 64$ With$$f$$ as any divisor of $$64$$, we can now equate factors on either side of this equation to obtain: $\begin{eqnarray}v-w\;&=&f\\v+w\;&=&64/f\end{eqnarray}$ Solving for $$v$$ and $$w$$ now gives:$\begin{eqnarray}2v\;&=&64/f+f\;&=&6m-20\\2w\;&=&64/f-f\;&=&12n-6m+12\end{eqnarray}$ and hence:$\begin{eqnarray}n\;&=&(32/f+2)/3\\m\;&=&n+(f+16)/6\end{eqnarray}$There are only a few divisors of 64 to try and $$f=2$$ produces a solution.
It is also easy to derive an alternative formulation which gives: $\begin{eqnarray} p\;&=&\;9k \\ n\;&=&\;2(k-1) \\ c\;&=&\;18k(k-1) \\ m\,&=&\;6k(k-1)/(3k-4)\end{eqnarray}$for integer $$k$$, which gives the solution for $$k=4$$
$$m = 2k + 1 + (4 – k)/(3k – 4)$$ makes it very apparent that $$k = 2$$ (c < 50) or $$k = 4$$