Solution to exercise 3 of UCL RSD course