problem 15 in ruby