Random coding in Scala