solved problem 95 in ruby