solved problem 35 again in ruby