Chapter 3 done

Review please
We can use a foreach loop to iterate over the @input array, rather than a while.