solved problem 43 again in ruby