Exercise 2 in Ruby