implemented problem 3 except for the solutions