Solution to the coding exercise