  We find an explicit form of weak solutions to a Riemann problem for a
degenerate semilinear parabolic equation with piecewise constant diffusion
coefficient. It is demonstrated that the phase transition lines (free
boundaries) correspond to the minimum point of some strictly convex function of
a finite number of variables. In the limit as number of phases tend to infinity
we obtain a variational formulation of self-similar solution with an arbitrary
nonnegative diffusion function.
