final solution to assignment 2