Solution to assignment 4