Solution in Scala for the first challenge problem of TPC.