Algorithms in Scala