Solve problems 6,120 using Scala.