Solution (source code)

= Solution

Expanding the squared <Euclidean distances> gives
$$
\|x-z_1\|^2-\|x-z_2\|^2
=-2x^{\mathsf T}(z_1-z_2)+\|z_1\|^2-\|z_2\|^2.
$$
For distinct <centroids>, choose
$$
\boxed{w=2(z_1-z_2),\qquad b=\|z_2\|^2-\|z_1\|^2}.
$$
A point assigned to $C_1$ has the displayed distance difference at most zero and therefore $w^{\mathsf T}x+b\ge0$; assignment to $C_2$ gives the reverse inequality. The separating <hyperplane> is the <perpendicular bisector> of the line segment joining the two <centroids>. Points tied between them lie on that <hyperplane>. This is the <nearest-centroid decision hyperplane>.

The requested nonzero $w$ needs the additional assumption $z_1\ne z_2$. It does not follow from the stated algorithm alone. In one dimension, take $C_1=\{-1,1\}$ and $C_2=\{0\}$, whose <centroids> are both zero. A tie rule that retains previous assignments can leave this configuration after an iteration. The inequalities at $-1,1$ imply $b\ge|w|$, while the inequality at zero implies $b\le0$, forcing $w=0$. Thus the unconditional nonzero-separator claim has this degenerate exception.