solution to problem 24