Solution to problem 51