Solution (source code)

= Solution
{c}

By <Jordan normal form>, each complex <nilpotent matrix> of size six can be put by <matrix similarity> into a <block diagonal matrix> whose <Nilpotent Jordan blocks> have sizes
$$
s_1\geq s_2\geq\cdots\geq s_k\geq1,\qquad \sum_{j=1}^k s_j=6.
$$
A <Nilpotent Jordan block> of size $s$ has <matrix rank> $s-1$ and <minimal polynomial> $t^s$. Therefore, for the whole <matrix>,
$$
\operatorname{rank}A=\sum_{j=1}^k(s_j-1)=6-k,\qquad m_A(t)=t^{s_1}.
$$
Thus the given <matrix rank> determines the number $k$ of <Jordan blocks>, and the given <minimal polynomial> determines the largest size $s_1$. For size six these two data determine the entire <integer partition>. Here is the complete list, arranged by the largest size:
$$
\begin{array}{c|c|c}
\text{block sizes}&k&\operatorname{rank}A\\\hline
(6)&1&5\\
(5,1)&2&4\\
(4,2)&2&4\\
(4,1,1)&3&3\\
(3,3)&2&4\\
(3,2,1)&3&3\\
(3,1,1,1)&4&2\\
(2,2,2)&3&3\\
(2,2,1,1)&4&2\\
(2,1,1,1,1)&5&1\\
(1,1,1,1,1,1)&6&0
\end{array}
$$
To see that the list is exhaustive, choose the largest part $s_1$ between one and six and partition the remainder $6-s_1$ into parts at most $s_1$. The resulting rows all have distinct pairs $(s_1,k)$. Hence $A$ and $B$ have the same <Jordan normal form> $J$.

Explicitly, choose <invertible matrices> $X,Y$ such that $A=XJX^{-1}$ and $B=YJY^{-1}$. Then
$$
\boxed{P=XY^{-1}\quad\Longrightarrow\quad P^{-1}AP=YJY^{-1}=B.}
$$
This proves <matrix similarity> and illustrates the <classification of six-dimensional nilpotent matrices by rank and nilpotency index>.