Solution to assignment 2