Solves exercise 1 from chapter 1, includes tests