solved problem 29 in ruby