Solved exercises 24-29 from chapter 6