A no-frills solution to exercise 6.