Solved Week 2 programming assignment