I used trial and error to factorise the following expression:
${9p^2 + 18p -16}$
I went through a number of different possibilities until I discovered the answer:
${(3p - 2)(3p + 8)}$
Is there an algorithm I could have used, using the coefficients or something that would be better?
Suppose $(rx + s)(tx + u) = ax^2 + bx + c$. Then \begin{align*} ax^2 + bx + c & = (rx + s)(tx + u)\\ & = rx(tx + u) + s(tx + u)\\ & = \color{blue}{rt}x^2 + \color{green}{ru}x + \color{green}{st}x + \color{blue}{su}\\ & = \color{blue}{rt}x^2 + (\color{green}{ru} + \color{green}{st})x + \color{blue}{su} \end{align*} Matching coefficients, we see that $a = rt$, $b = ru + st$, and $c = su$.
Observe that the product of the two coefficients that sum to the coefficient of the linear term is equal to the product of the coefficients of the quadratic and constant terms, that is, $$(\color{green}{ru})(\color{green}{st}) = (\color{blue}{rt})(\color{blue}{su}) = rstu$$
Thus, if a quadratic polynomial admits a factorization with respect to the rational numbers, the linear term splits into two numbers with product $ac$ and sum $b$.
In the example $9p^2 + 18p - 16$, we must find two numbers with product $9 \cdot -16 = -144$ and sum $18$. They are $-6$ and $24$. Hence, \begin{align*} 9p^2 + 18p - 16 & = 9p^2 - 6p + 24p - 16 && \text{split the linear term}\\ & = 3p(3p - 2) + 8(3p - 2) && \text{factor by grouping}\\ & = (3p + 8)(3p - 2) && \text{extract the common factor} \end{align*}