solved problem 55 in ruby