Blocket Contest Solution

As I mentioned last week, I have participated in a contest. In total, I got 17 points, which means 7 extra points out of 10 for my solution in the last challenge. That puts me in place 28 or place 3, depending on if you consider everybody with the same points in the same place or not.

Here comes my solution. The problem description can be found in the picture above.