Add Scala solution for problem 3.