problem 76 in Ruby