Solution of assignment 2.