added Scala solution for question 2