My take on the assignment

Implementation of question 1. Time taken: 50 minutes.