solved problem 25 with Ruby