solved exercises 1 to 6 in chapter3