Solution to Assignment 2.