My solution for programming assignment 2