solved problem 10 again in ruby