Solution of programming assignment 2 (peer assessment)