------art_24318_5344479.1151276969935
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hi everyone,
here's my own solution to the problem:

pascal.rb
------
class Pascal
  attr_reader :triangle

  def initialize(rows)
    @triangle
    generate(rows)
  end

  def [](row, n)
    if row>0 and row<riangle.length and n>0 and n<@triangle[row-1].length
      @triangle[row-1][n-1]
    else
      nil
    end
  end

  def generate(rows)
    return nil if rows<@triangle.length
    rows.times do |s|
      row]
      1.upto(s-1) do |n|
        row[n]riangle[s-1][n-1]+@triangle[s-1][n]
      end
      row[s]      @triangle << row
    end
  end

  def to_s
    spacingriangle.last.max.to_s.length
    total_lengthpacing+1)*@triangle.last.length
    @triangle.map do |row|
      row.map do |number|
        number.to_s.center(spacing)
      end.join(" ").center(total_length)
    end.join("\n")
  end

end

puts Pascal.new(ARGV[0].to_i)

------

------art_24318_5344479.1151276969935--