exercise 5 in ruby