Various code exercises in Scala