Triangle Problem in Ruby