Solution to problem 79. Too slow.