solved problem 19 in ruby. ruby is so awesome