Solution (source code)

= Solution

Direct contact permits no work extraction, so conservation of internal energy gives
$$
C_V(T_f-T_1)+C_V(T_f-T_2)=0,
\qquad
\boxed{T_f=\frac{T_1+T_2}{2}}.
$$
The total entropy change is
$$
\begin{aligned}
\Delta S
&=C_V\log\frac{T_f}{T_1}
+C_V\log\frac{T_f}{T_2}\\
&=C_V\log\frac{(T_1+T_2)^2}{4T_1T_2}\geq0.
\end{aligned}
$$
The <arithmetic-geometric mean inequality> makes the last expression positive when $T_1\ne T_2$, with equality only when the bodies were already at the same temperature. This is the entropy production of irreversible heat flow.