Initial implementation of problem 3 (with solution)