solved problem 1 again in ruby