Code for the second assignment in the Coursera Scala course I'm taking