Solution (source code)

= Solution

The elementary <row operation> $R_2\leftarrow R_2+3R_1$ gives
$$
\begin{pmatrix}1&4&2\\0&a+12&0\\0&0&b\end{pmatrix}.
$$
The nonzero rows here have distinct <pivots>. Therefore the <matrix rank> is
$$
\boxed{\operatorname{rank}A=\begin{cases}
3,&a\ne-12,\ b\ne0,\\
2,&\text{exactly one of }a=-12,\ b=0\text{ holds},\\
1,&a=-12,\ b=0.
\end{cases}}
$$
There is always at least one nonzero row, so rank zero is impossible.