problem 29

passed after consulting the answer