Solve problem 5
Fix algorithm return value in problem 3