Solution (source code)

= Solution

Mass and <momentum> conservation are
$$
\rho_t+(\rho u)_x=0,
\qquad
u_t+uu_x+\frac1\rho p_x=0.
$$
For homentropic ideal-gas flow, $c^2=dp/d\rho$ and
$$
\frac{dc}{c}=\frac{\gamma-1}{2}\frac{d\rho}{\rho}.
$$
Combining the two conservation equations then gives
$$
(\partial_t+(u\pm c)\partial_x)
\left(u\pm\frac{2c}{\gamma-1}\right)=0.
$$
Subtracting the harmless constant $\pm2c_0/(\gamma-1)$ proves that each <Riemann invariant>
$$
R_\pm=u\pm\frac{2(c-c_0)}{\gamma-1}
$$
is constant on $C_\pm$, where $dx/dt=u\pm c$.