solved problem 92 in ruby