solved problem 97 again in ruby