Implements solution to exercises chapter 5