problem 65 in Ruby