problem 9 - scala