"Mars rover" problem in Scala.