solved problem 37 again in ruby