problem 89 in Ruby