News for hackers. Stuff that matters.

z324werwer

Re:Why 37signals Doesn't Hire Programmers Based on Brainteasers on Thursday January 05, 2012 @03:29PM (#3430352)
u mad bro? your solution looks quite ugly

in ruby

   def fact(n)
     n == 0 ? 1 : n.downto(1).inject(:*)
   end

  def pascal(n)
   0.upto(n) {|r| print "#{fact(n)/(fact(r)*fact(n - r))} "}
  end
Re:Why 37signals Doesn't Hire Programmers Based on Brainteasers on Thursday January 05, 2012 @03:27PM (#3430343)
u mad bro, that u had to write so many lines, and yet your code couldn't print out pascal(5000)

u mad?

in ruby,

  def fact(n)
    n == 0 ? 1 : n.downto(1).inject(:*)
    end

  def pascal(n)
   0.upto(n) {|r| print "#{fact(n)/(fact(r)*fact(n - r))} "}
  end