Solution (source code)

= Solution

The <parallel axis theorem> says that for an axis through $x$, parallel to the centre-of-mass axis in direction $\hat d$,
$$
I_T(x)=I_T(x_T)+M_T|(x-x_T)\times\hat d|^2.
$$
Let
$$
\rho_A^2=|(x_A-x_C)\times\hat d|^2,
\qquad
\rho_B^2=|(x_B-x_C)\times\hat d|^2.
$$
Moments about the axis through $x_C$ add, so
$$
I_C(x_C)=I_A(x_A)+M_A\rho_A^2
+I_B(x_B)+M_B\rho_B^2.
$$
Using $M_A=M_C-M_B$ and solving gives
$$
\boxed{
M_B=\frac{I_C(x_C)-I_A(x_A)-I_B(x_B)-M_C\rho_A^2}
{\rho_B^2-\rho_A^2}}
$$
when the denominator is nonzero. In the degenerate equal-distance case, this inertia equation alone does not determine $M_B$; the centre-of-mass equation $M_Cx_C=M_Ax_A+M_Bx_B$ supplies the remaining information.