programming assignment 3, adding solution to second problem