Re-implemented exercise 1.13 using arrays