solved exercise 2 from multidimensional arrays