solved problem 19 again in ruby