Solution to exercise 1