solution to Problem 24 Amzing solution