Implemented exercise 1 from assignment 3.