problem 64 in Ruby