Adding solution to the second homework.