solved exercise 12 from arrays