solved problem 13 again in ruby