Solution to task 2 from week6 exam