added scala implementation of problem 1