Solution to problem C