Problem 2 solution.
Problem 3 solution
Add test for infinite lists (problem 3)