solved problem 42 again in ruby