Codility Train Exercises in Scala