Data and solution for problem 5

The code is UGLY, but comes to the right conclusion...