Solution (source code)

= Solution
{c}

For this <tripotent linear operator>, the relation $T^3=T$ gives $T(T^2-I)=0$. Since $T^2\ne I$, there is $v$ with $(T^2-I)v\ne0$, and that nonzero <vector> belongs to $\ker T$. Hence $n_T\geq1$. Also $T\ne0$, because $T=0$ would imply $T^2=T$. The <rank-nullity theorem> in <dimension> three therefore gives
$$
\boxed{n_T\in\{1,2\}.}
$$
Now suppose $n_T=2$. Then $\operatorname{im}T$ is a line. On this line, $T^2$ is the <identity operator>: if $y=Tx$, then $T^2y=T^3x=Tx=y$. Consequently $T$ acts on this line by a <scalar> $c$ satisfying $c^2=1$. If $c=1$, then $T^2x=Tx$ for every $x$, contrary to $T^2\ne T$. Thus $c=-1$.

Choose a nonzero $w\in\operatorname{im}T$, so $Tw=-w$. It does not belong to $\ker T$. A <basis> $k_1,k_2$ of $\ker T$, followed by $w$, is therefore a <basis> of $V$, in which
$$
\boxed{[T]_{(k_1,k_2,w)}=\begin{pmatrix}0&0&0\\0&0&0\\0&0&-1\end{pmatrix}.}
$$