My answer to programming assignment 2.