Week 4 assignment of Functional Programming in Scala @ Coursera