solved problem 14 again in ruby